diff options
author | Colm Donelan <Colm.Donelan@arm.com> | 2021-10-12 15:06:19 +0100 |
---|---|---|
committer | Matthew Sloyan <matthew.sloyan@arm.com> | 2021-10-18 10:42:15 +0000 |
commit | 3cff15a5d8797d0afe5d5b1cb3ff0e5b7d1cd6c9 (patch) | |
tree | 47a203daa2fee1f7afc3e79787cf2e99c52473da /tests/ExecuteNetwork/ExecuteNetworkParams.cpp | |
parent | b4128b4c8c8c717225c83debc5f957d37d6513fa (diff) | |
download | armnn-3cff15a5d8797d0afe5d5b1cb3ff0e5b7d1cd6c9.tar.gz |
IVGCVSW-5879 Pass the execute network parameters to the TfLiteDelegate.
* Introduce a mechanism to construct a DelegateOptions from an
ExecuteNetworkParams.
* Modify ExecuteNetwork to use this constructed DelegateOptions.
Signed-off-by: Colm Donelan <Colm.Donelan@arm.com>
Change-Id: Ied663a1e00ac3eece42244ed313ddafd6d2ce078
Diffstat (limited to 'tests/ExecuteNetwork/ExecuteNetworkParams.cpp')
-rw-r--r-- | tests/ExecuteNetwork/ExecuteNetworkParams.cpp | 58 |
1 files changed, 57 insertions, 1 deletions
diff --git a/tests/ExecuteNetwork/ExecuteNetworkParams.cpp b/tests/ExecuteNetwork/ExecuteNetworkParams.cpp index dcdd423246..541430c421 100644 --- a/tests/ExecuteNetwork/ExecuteNetworkParams.cpp +++ b/tests/ExecuteNetwork/ExecuteNetworkParams.cpp @@ -232,4 +232,60 @@ void ExecuteNetworkParams::ValidateParams() { ARMNN_LOG(warning) << "No input files provided, input tensors will be filled with 0s."; } -}
\ No newline at end of file +} + +#if defined(ARMNN_TFLITE_DELEGATE) +/** + * A utility method that populates a DelegateOptions object from this ExecuteNetworkParams. + * + * @return a populated armnnDelegate::DelegateOptions object. + */ +armnnDelegate::DelegateOptions ExecuteNetworkParams::ToDelegateOptions() const +{ + armnnDelegate::DelegateOptions delegateOptions(m_ComputeDevices); + delegateOptions.SetDynamicBackendsPath(m_DynamicBackendsPath); + delegateOptions.SetGpuProfilingState(m_EnableProfiling); + + armnn::OptimizerOptions options; + options.m_ReduceFp32ToFp16 = m_EnableFp16TurboMode; + options.m_ReduceFp32ToBf16 = m_EnableBf16TurboMode; + options.m_Debug = m_PrintIntermediate; + + options.m_shapeInferenceMethod = armnn::ShapeInferenceMethod::ValidateOnly; + if (m_InferOutputShape) + { + options.m_shapeInferenceMethod = armnn::ShapeInferenceMethod::InferAndValidate; + } + + armnn::BackendOptions gpuAcc("GpuAcc", + { + { "FastMathEnabled", m_EnableFastMath }, + { "SaveCachedNetwork", m_SaveCachedNetwork }, + { "CachedNetworkFilePath", m_CachedNetworkFilePath }, + { "TuningLevel", m_TuningLevel}, + { "TuningFile", m_TuningPath.c_str()}, + { "KernelProfilingEnabled", m_EnableProfiling}, + { "MLGOTuningFilePath", m_MLGOTuningFilePath} + }); + + armnn::BackendOptions cpuAcc("CpuAcc", + { + { "FastMathEnabled", m_EnableFastMath }, + { "NumberOfThreads", m_NumberOfThreads } + }); + options.m_ModelOptions.push_back(gpuAcc); + options.m_ModelOptions.push_back(cpuAcc); + + delegateOptions.SetOptimizerOptions(options); + + // If v,visualize-optimized-model is enabled then construct a file name for the dot file. + if (m_EnableLayerDetails) + { + fs::path filename = m_ModelPath; + filename.replace_extension("dot"); + delegateOptions.SetSerializeToDot(filename); + } + + return delegateOptions; +} +#endif |