From d1a947fd487eb7674271f759e43507d10e932ab0 Mon Sep 17 00:00:00 2001 From: Narumol Prangnawarat Date: Mon, 7 Feb 2022 13:12:24 +0000 Subject: Revert "Revert "IVGCVSW-6700 Enable import aligned host memory in android-nn-driver"" This reverts commit 8069603dc44b7673b356f66517cd8b25af8080f0. * Reason for revert: Try reenable import aligned host memory in android-nn-driver * Added a check to ArmNNDriverImpl.cpp to not call ExecuteWithDummyInputs with GpuAcc * Added new android-nn-driver driver options to enable / disable Import and Export * Import is disabled by default for now due to conv2d issues * Export is enabled by default !armnn:7147 Change-Id: I91110c58ebb3931d1c458e3774944e55c1250dd8 Signed-off-by: David Monahan --- ArmnnPreparedModel_1_3.cpp | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'ArmnnPreparedModel_1_3.cpp') diff --git a/ArmnnPreparedModel_1_3.cpp b/ArmnnPreparedModel_1_3.cpp index 36575b86..34c42ecd 100644 --- a/ArmnnPreparedModel_1_3.cpp +++ b/ArmnnPreparedModel_1_3.cpp @@ -12,6 +12,8 @@ #include "ArmnnPreparedModel_1_3.hpp" #include "Utils.hpp" +#include + #include #include #include @@ -172,7 +174,9 @@ ArmnnPreparedModel_1_3::ArmnnPreparedModel_1_3(armnn::NetworkId netw const bool gpuProfilingEnabled, V1_3::Priority priority, const bool asyncModelExecutionEnabled, - const unsigned int numberOfThreads) + const unsigned int numberOfThreads, + const bool importEnabled, + const bool exportEnabled) : m_NetworkId(networkId) , m_Runtime(runtime) , m_Model(model) @@ -181,6 +185,8 @@ ArmnnPreparedModel_1_3::ArmnnPreparedModel_1_3(armnn::NetworkId netw , m_GpuProfilingEnabled(gpuProfilingEnabled) , m_ModelPriority(priority) , m_AsyncModelExecutionEnabled(asyncModelExecutionEnabled) + , m_EnableImport(importEnabled) + , m_EnableExport(exportEnabled) , m_PreparedFromCache(false) { // Enable profiling if required. @@ -215,6 +221,8 @@ ArmnnPreparedModel_1_3::ArmnnPreparedModel_1_3(armnn::NetworkId netw V1_3::Priority priority, const bool asyncModelExecutionEnabled, const unsigned int numberOfThreads, + const bool importEnabled, + const bool exportEnabled, const bool preparedFromCache) : m_NetworkId(networkId) , m_Runtime(runtime) @@ -223,6 +231,8 @@ ArmnnPreparedModel_1_3::ArmnnPreparedModel_1_3(armnn::NetworkId netw , m_GpuProfilingEnabled(gpuProfilingEnabled) , m_ModelPriority(priority) , m_AsyncModelExecutionEnabled(asyncModelExecutionEnabled) + , m_EnableImport(importEnabled) + , m_EnableExport(exportEnabled) , m_PreparedFromCache(preparedFromCache) { // Enable profiling if required. @@ -824,7 +834,19 @@ Return ArmnnPreparedModel_1_3::ExecuteGraph( else { ALOGW("ArmnnPreparedModel_1_3::ExecuteGraph m_AsyncModelExecutionEnabled false"); - status = m_Runtime->EnqueueWorkload(m_NetworkId, inputTensors, outputTensors); + // Create a vector of Input and Output Ids which can be imported. An empty vector means all will be copied. + std::vector importedInputIds; + if (m_EnableImport) + { + importedInputIds = m_Runtime->ImportInputs(m_NetworkId, inputTensors, armnn::MemorySource::Malloc); + } + std::vector importedOutputIds; + if (m_EnableExport) + { + importedOutputIds = m_Runtime->ImportOutputs(m_NetworkId, outputTensors, armnn::MemorySource::Malloc); + } + status = m_Runtime->EnqueueWorkload(m_NetworkId, inputTensors, outputTensors, + importedInputIds, importedOutputIds); } if (cb.ctx.measureTimings == V1_2::MeasureTiming::YES) -- cgit v1.2.1