diff options
author | Matthew Sloyan <matthew.sloyan@arm.com> | 2021-04-27 17:16:12 +0100 |
---|---|---|
committer | Matthew Sloyan <matthew.sloyan@arm.com> | 2021-04-28 11:16:36 +0000 |
commit | c2b99a8783388ec3bd90dfed2e1b6d4f4d4bd1c8 (patch) | |
tree | 79532141b41ae18ce344ee4c1f469ce2e3310dd1 /delegate/src | |
parent | 2241d18f16878ddef261eadda9a0a8f0672a60c8 (diff) | |
download | armnn-c2b99a8783388ec3bd90dfed2e1b6d4f4d4bd1c8.tar.gz |
IVGCVSW-5831 Add additional options to Arm NN External Delegate
* Added enable-fast-math and number-of-threads options.
* Added save-cached-network and cached-network-filepath options.
* Added external_delegate python tests for new options.
Signed-off-by: Matthew Sloyan <matthew.sloyan@arm.com>
Change-Id: I7cf6522a6f895cd71ed8f369d94a5113d78594f9
Diffstat (limited to 'delegate/src')
-rw-r--r-- | delegate/src/armnn_external_delegate.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/delegate/src/armnn_external_delegate.cpp b/delegate/src/armnn_external_delegate.cpp index edf46efb98..27eaf64f73 100644 --- a/delegate/src/armnn_external_delegate.cpp +++ b/delegate/src/armnn_external_delegate.cpp @@ -4,6 +4,7 @@ // #include "armnn_delegate.hpp" #include <armnn/Logging.hpp> +#include <armnn/utility/NumericCast.hpp> #include <iostream> #include <tensorflow/lite/minimal_logging.h> @@ -54,6 +55,10 @@ std::vector<std::string> gpu_options {"gpu-tuning-level", * 1,2 and 3 will create a tuning-file, 0 will apply the * tunings from an existing file * + * Option key: "gpu-mlgo-tuning-file" \n + * Possible values: [filenameString] \n + * Description: File name for the MLGO tuning file + * * Option key: "gpu-tuning-file" \n * Possible values: [filenameString] \n * Description: File name for the tuning file. @@ -62,6 +67,28 @@ std::vector<std::string> gpu_options {"gpu-tuning-level", * Possible values: ["true"/"false"] \n * Description: Enables GPU kernel profiling * + * Option key: "save-cached-network" \n + * Possible values: ["true"/"false"] \n + * Description: Enables saving of the cached network to a file, + * specified with the cached-network-filepath option + * + * Option key: "cached-network-filepath" \n + * Possible values: [filenameString] \n + * Description: If non-empty, the given file will be used to load/save the cached network. + * If save-cached-network is given then the cached network will be saved to the given file. + * To save the cached network a file must already exist. + * If save-cached-network is not given then the cached network will be loaded from the given file. + * This will remove initial compilation time of kernels and speed up the first execution. + * + * Option key: "enable-fast-math" \n + * Possible values: ["true"/"false"] \n + * Description: Enables fast_math options in backends that support it + * + * Option key: "number-of-threads" \n + * Possible values: ["1"-"64"] \n + * Description: Assign the number of threads used by the CpuAcc backend. + * Default is set to 0 (Backend will decide number of threads to use). + * * Option key: "reduce-fp32-to-fp16" \n * Possible values: ["true"/"false"] \n * Description: Reduce Fp32 data to Fp16 for faster processing @@ -140,6 +167,32 @@ TfLiteDelegate* tflite_plugin_create_delegate(char** options_keys, armnn::BackendOptions option("GpuAcc", {{"KernelProfilingEnabled", (*options_values[i] != '0')}}); options.AddBackendOption(option); } + else if (std::string(options_keys[i]) == std::string("save-cached-network")) + { + armnn::BackendOptions option("GpuAcc", {{"SaveCachedNetwork", (*options_values[i] != '0')}}); + optimizerOptions.m_ModelOptions.push_back(option); + } + else if (std::string(options_keys[i]) == std::string("cached-network-filepath")) + { + armnn::BackendOptions option("GpuAcc", {{"CachedNetworkFilePath", std::string(options_values[i])}}); + optimizerOptions.m_ModelOptions.push_back(option); + } + // Process GPU & CPU backend options + else if (std::string(options_keys[i]) == std::string("enable-fast-math")) + { + armnn::BackendOptions modelOptionGpu("GpuAcc", {{"FastMathEnabled", (*options_values[i] != '0')}}); + optimizerOptions.m_ModelOptions.push_back(modelOptionGpu); + + armnn::BackendOptions modelOptionCpu("CpuAcc", {{"FastMathEnabled", (*options_values[i] != '0')}}); + optimizerOptions.m_ModelOptions.push_back(modelOptionCpu); + } + // Process CPU backend options + else if (std::string(options_keys[i]) == std::string("number-of-threads")) + { + unsigned int numberOfThreads = armnn::numeric_cast<unsigned int>(atoi(options_values[i])); + armnn::BackendOptions modelOption("CpuAcc", {{"NumberOfThreads", numberOfThreads}}); + optimizerOptions.m_ModelOptions.push_back(modelOption); + } // Process reduce-fp32-to-fp16 option else if (std::string(options_keys[i]) == std::string("reduce-fp32-to-fp16")) { |