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_2.cpp | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'ArmnnPreparedModel_1_2.cpp') diff --git a/ArmnnPreparedModel_1_2.cpp b/ArmnnPreparedModel_1_2.cpp index 7f35e60f..37bc3a49 100644 --- a/ArmnnPreparedModel_1_2.cpp +++ b/ArmnnPreparedModel_1_2.cpp @@ -9,6 +9,8 @@ #include "Utils.hpp" +#include + #include #include #include @@ -151,7 +153,9 @@ ArmnnPreparedModel_1_2::ArmnnPreparedModel_1_2(armnn::NetworkId netw const std::string& requestInputsAndOutputsDumpDir, const bool gpuProfilingEnabled, 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) @@ -159,6 +163,8 @@ ArmnnPreparedModel_1_2::ArmnnPreparedModel_1_2(armnn::NetworkId netw , m_RequestInputsAndOutputsDumpDir(requestInputsAndOutputsDumpDir) , m_GpuProfilingEnabled(gpuProfilingEnabled) , m_AsyncModelExecutionEnabled(asyncModelExecutionEnabled) + , m_EnableImport(importEnabled) + , m_EnableExport(exportEnabled) , m_PreparedFromCache(false) { // Enable profiling if required. @@ -192,6 +198,8 @@ ArmnnPreparedModel_1_2::ArmnnPreparedModel_1_2(armnn::NetworkId netw const bool gpuProfilingEnabled, const bool asyncModelExecutionEnabled, const unsigned int numberOfThreads, + const bool importEnabled, + const bool exportEnabled, const bool preparedFromCache) : m_NetworkId(networkId) , m_Runtime(runtime) @@ -199,6 +207,8 @@ ArmnnPreparedModel_1_2::ArmnnPreparedModel_1_2(armnn::NetworkId netw , m_RequestInputsAndOutputsDumpDir(requestInputsAndOutputsDumpDir) , m_GpuProfilingEnabled(gpuProfilingEnabled) , m_AsyncModelExecutionEnabled(asyncModelExecutionEnabled) + , m_EnableImport(importEnabled) + , m_EnableExport(exportEnabled) , m_PreparedFromCache(preparedFromCache) { // Enable profiling if required. @@ -531,7 +541,20 @@ bool ArmnnPreparedModel_1_2::ExecuteGraph( else { ALOGW("ArmnnPreparedModel_1_2::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