aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Flynn <jim.flynn@arm.com>2022-02-15 16:53:13 +0000
committerJim Flynn <jim.flynn@arm.com>2022-02-15 16:55:27 +0000
commit154258132955f0bd74ef26a0cc20b7daca4d7b09 (patch)
treee663b631c40800d0503f5316449b8707cb9da19b
parent5e7335b8ac8a63b81706316fda11348579a04726 (diff)
downloadarmnn-154258132955f0bd74ef26a0cc20b7daca4d7b09.tar.gz
IVGCVSW-6786 Add import if memory aligned option to ExecuteNetwork
Change-Id: Ib038e7b2616195a64715e3a7126da1368bbca1d3 Signed-off-by: Jim Flynn <jim.flynn@arm.com>
-rw-r--r--tests/ExecuteNetwork/ExecuteNetwork.cpp1
-rw-r--r--tests/ExecuteNetwork/ExecuteNetworkParams.hpp1
-rw-r--r--tests/ExecuteNetwork/ExecuteNetworkProgramOptions.cpp6
-rw-r--r--tests/InferenceModel.hpp32
4 files changed, 34 insertions, 6 deletions
diff --git a/tests/ExecuteNetwork/ExecuteNetwork.cpp b/tests/ExecuteNetwork/ExecuteNetwork.cpp
index 1f19584c68..92a2946847 100644
--- a/tests/ExecuteNetwork/ExecuteNetwork.cpp
+++ b/tests/ExecuteNetwork/ExecuteNetwork.cpp
@@ -405,6 +405,7 @@ int MainImpl(const ExecuteNetworkParams& params,
inferenceModelParams.m_ThreadPoolSize = params.m_ThreadPoolSize;
inferenceModelParams.m_OutputDetailsToStdOut = params.m_OutputDetailsToStdOut;
inferenceModelParams.m_OutputDetailsOnlyToStdOut = params.m_OutputDetailsOnlyToStdOut;
+ inferenceModelParams.m_ImportInputsIfAligned = params.m_ImportInputsIfAligned;
for(const std::string& inputName: params.m_InputNames)
{
diff --git a/tests/ExecuteNetwork/ExecuteNetworkParams.hpp b/tests/ExecuteNetwork/ExecuteNetworkParams.hpp
index cb8c2fb386..deaf55f6e5 100644
--- a/tests/ExecuteNetwork/ExecuteNetworkParams.hpp
+++ b/tests/ExecuteNetwork/ExecuteNetworkParams.hpp
@@ -65,6 +65,7 @@ struct ExecuteNetworkParams
std::string m_MLGOTuningFilePath;
TfLiteExecutor m_TfLiteExecutor;
size_t m_ThreadPoolSize;
+ bool m_ImportInputsIfAligned;
// Ensures that the parameters for ExecuteNetwork fit together
void ValidateParams();
diff --git a/tests/ExecuteNetwork/ExecuteNetworkProgramOptions.cpp b/tests/ExecuteNetwork/ExecuteNetworkProgramOptions.cpp
index 8ee66cf64b..681dc8a611 100644
--- a/tests/ExecuteNetwork/ExecuteNetworkProgramOptions.cpp
+++ b/tests/ExecuteNetwork/ExecuteNetworkProgramOptions.cpp
@@ -423,8 +423,12 @@ ProgramOptions::ProgramOptions() : m_CxxOptions{"ExecuteNetwork",
("output-network-details-only",
"Outputs layer tensor infos and descriptors to std out without profiling events. Defaults to off.",
cxxopts::value<bool>(m_ExNetParams.m_OutputDetailsOnlyToStdOut)->default_value("false")
- ->implicit_value("true"));
+ ->implicit_value("true"))
+ ("import-inputs-if-aligned",
+ "In & Out tensors will be imported per inference if the memory alignment allows. Defaults to false.",
+ cxxopts::value<bool>(m_ExNetParams.m_ImportInputsIfAligned)->default_value("false")
+ ->implicit_value("true"));
}
catch (const std::exception& e)
{
diff --git a/tests/InferenceModel.hpp b/tests/InferenceModel.hpp
index bddaf557fd..e2a1a97568 100644
--- a/tests/InferenceModel.hpp
+++ b/tests/InferenceModel.hpp
@@ -111,6 +111,7 @@ struct Params
std::string m_MLGOTuningFilePath;
bool m_AsyncEnabled;
size_t m_ThreadPoolSize;
+ bool m_ImportInputsIfAligned;
Params()
@@ -132,6 +133,7 @@ struct Params
, m_MLGOTuningFilePath("")
, m_AsyncEnabled(false)
, m_ThreadPoolSize(0)
+ , m_ImportInputsIfAligned(false)
{}
};
@@ -438,8 +440,9 @@ public:
const std::string& dynamicBackendsPath,
const std::shared_ptr<armnn::IRuntime>& runtime = nullptr)
: m_EnableProfiling(enableProfiling),
- m_ProfilingDetailsMethod(armnn::ProfilingDetailsMethod::Undefined)
- , m_DynamicBackendsPath(dynamicBackendsPath)
+ m_ProfilingDetailsMethod(armnn::ProfilingDetailsMethod::Undefined),
+ m_DynamicBackendsPath(dynamicBackendsPath),
+ m_ImportInputsIfAligned(params.m_ImportInputsIfAligned)
{
if (runtime)
{
@@ -612,9 +615,27 @@ public:
// Start timer to record inference time in EnqueueWorkload (in milliseconds)
const auto start_time = armnn::GetTimeNow();
- armnn::Status ret = m_Runtime->EnqueueWorkload(m_NetworkIdentifier,
- MakeInputTensors(inputContainers),
- MakeOutputTensors(outputContainers));
+ armnn::Status ret;
+ if (m_ImportInputsIfAligned)
+ {
+ std::vector<armnn::ImportedInputId> importedInputIds = m_Runtime->ImportInputs(
+ m_NetworkIdentifier, MakeInputTensors(inputContainers), armnn::MemorySource::Malloc);
+
+ std::vector<armnn::ImportedOutputId> importedOutputIds = m_Runtime->ImportOutputs(
+ m_NetworkIdentifier, MakeOutputTensors(outputContainers), armnn::MemorySource::Malloc);
+
+ ret = m_Runtime->EnqueueWorkload(m_NetworkIdentifier,
+ MakeInputTensors(inputContainers),
+ MakeOutputTensors(outputContainers),
+ importedInputIds,
+ importedOutputIds);
+ }
+ else
+ {
+ ret = m_Runtime->EnqueueWorkload(m_NetworkIdentifier,
+ MakeInputTensors(inputContainers),
+ MakeOutputTensors(outputContainers));
+ }
const auto duration = armnn::GetTimeDuration(start_time);
// if profiling is enabled print out the results
@@ -784,6 +805,7 @@ private:
bool m_EnableProfiling;
armnn::ProfilingDetailsMethod m_ProfilingDetailsMethod;
std::string m_DynamicBackendsPath;
+ bool m_ImportInputsIfAligned;
template<typename TContainer>
armnn::InputTensors MakeInputTensors(const std::vector<TContainer>& inputDataContainers)