aboutsummaryrefslogtreecommitdiff
path: root/delegate/src
diff options
context:
space:
mode:
authorNarumol Prangnawarat <narumol.prangnawarat@arm.com>2021-01-29 15:38:54 +0000
committerNarumol Prangnawarat <narumol.prangnawarat@arm.com>2021-02-02 13:53:38 +0000
commit74a3cf5755b801cf258177e8e55b4cda64a0c351 (patch)
tree01246003e2b336e75095d148000370a17e790511 /delegate/src
parentbd4fcc30a3732ce63e100d556ee5c9ea9e556c05 (diff)
downloadarmnn-74a3cf5755b801cf258177e8e55b4cda64a0c351.tar.gz
IVGCVSW-5619 Enable OptimizerOptions for the python external delegate
* Add reduce-fp32-to-fp16, reduce-fp32-to-bf16, debug-data, memory-import options to external delegate * Simplify DelegateOptions * Add test mock models * Unit tests * Configure lfs to manage tflite files Signed-off-by: Narumol Prangnawarat <narumol.prangnawarat@arm.com> Change-Id: I1e4db468862ba03d4cb031347bc307cf940b3cb1
Diffstat (limited to 'delegate/src')
-rw-r--r--delegate/src/DelegateOptions.cpp4
-rw-r--r--delegate/src/armnn_delegate.cpp19
-rw-r--r--delegate/src/armnn_external_delegate.cpp38
-rw-r--r--delegate/src/test/DelegateOptionsTest.cpp12
4 files changed, 57 insertions, 16 deletions
diff --git a/delegate/src/DelegateOptions.cpp b/delegate/src/DelegateOptions.cpp
index 400bf78766..d4d906a83a 100644
--- a/delegate/src/DelegateOptions.cpp
+++ b/delegate/src/DelegateOptions.cpp
@@ -24,13 +24,11 @@ DelegateOptions::DelegateOptions(const std::vector<armnn::BackendId>& backends,
DelegateOptions::DelegateOptions(armnn::Compute computeDevice,
const armnn::OptimizerOptions& optimizerOptions,
- const armnn::INetworkProperties& networkProperties,
const armnn::Optional<armnn::LogSeverity>& logSeverityLevel,
const armnn::Optional<armnn::DebugCallbackFunction>& func)
: m_Backends({computeDevice}),
m_BackendOptions({}),
m_OptimizerOptions(optimizerOptions),
- m_NetworkProperties(networkProperties),
m_LoggingSeverity(logSeverityLevel),
m_DebugCallbackFunc(func)
{
@@ -38,13 +36,11 @@ DelegateOptions::DelegateOptions(armnn::Compute computeDevice,
DelegateOptions::DelegateOptions(const std::vector<armnn::BackendId>& backends,
const armnn::OptimizerOptions& optimizerOptions,
- const armnn::INetworkProperties& networkProperties,
const armnn::Optional<armnn::LogSeverity>& logSeverityLevel,
const armnn::Optional<armnn::DebugCallbackFunction>& func)
: m_Backends(backends),
m_BackendOptions({}),
m_OptimizerOptions(optimizerOptions),
- m_NetworkProperties(networkProperties),
m_LoggingSeverity(logSeverityLevel),
m_DebugCallbackFunc(func)
{
diff --git a/delegate/src/armnn_delegate.cpp b/delegate/src/armnn_delegate.cpp
index 6f72d864b9..639e514a78 100644
--- a/delegate/src/armnn_delegate.cpp
+++ b/delegate/src/armnn_delegate.cpp
@@ -353,10 +353,21 @@ ArmnnSubgraph* ArmnnSubgraph::Create(TfLiteContext* tfLiteContext,
{
// Load graph into runtime
std::string errorMessage;
- auto loadingStatus = delegate->m_Runtime->LoadNetwork(networkId,
- std::move(optNet),
- errorMessage,
- delegate->m_Options.GetNetworkProperties());
+ armnn::Status loadingStatus;
+ if (delegate->m_Options.GetOptimizerOptions().m_ImportEnabled)
+ {
+ armnn::INetworkProperties networkProperties(true, true);
+ loadingStatus = delegate->m_Runtime->LoadNetwork(networkId,
+ std::move(optNet),
+ errorMessage,
+ networkProperties);
+ }
+ else
+ {
+ loadingStatus = delegate->m_Runtime->LoadNetwork(networkId,
+ std::move(optNet),
+ errorMessage);
+ }
if (loadingStatus != armnn::Status::Success)
{
// Optimize failed
diff --git a/delegate/src/armnn_external_delegate.cpp b/delegate/src/armnn_external_delegate.cpp
index 53b17256af..4dba07d3b8 100644
--- a/delegate/src/armnn_external_delegate.cpp
+++ b/delegate/src/armnn_external_delegate.cpp
@@ -62,6 +62,22 @@ std::vector<std::string> gpu_options {"gpu-tuning-level",
* Possible values: ["true"/"false"] \n
* Description: Enables GPU kernel profiling
*
+ * Option key: "reduce-fp32-to-fp16" \n
+ * Possible values: ["true"/"false"] \n
+ * Description: Reduce Fp32 data to Fp16 for faster processing
+ *
+ * Option key: "reduce-fp32-to-bf16" \n
+ * Possible values: ["true"/"false"] \n
+ * Description: Reduce Fp32 data to Bf16 for faster processing
+ *
+ * Option key: "debug-data" \n
+ * Possible values: ["true"/"false"] \n
+ * Description: Add debug data for easier troubleshooting
+ *
+ * Option key: "memory-import" \n
+ * Possible values: ["true"/"false"] \n
+ * Description: Enable memory import
+ *
*
* @param[in] option_keys Delegate option names
* @param[in] options_values Delegate option values
@@ -81,6 +97,7 @@ TfLiteDelegate* tflite_plugin_create_delegate(char** options_keys,
{
// (Initializes with CpuRef backend)
armnnDelegate::DelegateOptions options = armnnDelegate::TfLiteArmnnDelegateOptionsDefault();
+ armnn::OptimizerOptions optimizerOptions;
for (size_t i = 0; i < num_options; ++i)
{
// Process backends
@@ -118,11 +135,32 @@ TfLiteDelegate* tflite_plugin_create_delegate(char** options_keys,
armnn::BackendOptions option("GpuAcc", {{"KernelProfilingEnabled", (*options_values[i] != '0')}});
options.AddBackendOption(option);
}
+ // Process reduce-fp32-to-fp16 option
+ else if (std::string(options_keys[i]) == std::string("reduce-fp32-to-fp16"))
+ {
+ optimizerOptions.m_ReduceFp32ToFp16 = *options_values[i] != '0';
+ }
+ // Process reduce-fp32-to-bf16 option
+ else if (std::string(options_keys[i]) == std::string("reduce-fp32-to-bf16"))
+ {
+ optimizerOptions.m_ReduceFp32ToBf16 = *options_values[i] != '0';
+ }
+ // Process debug-data
+ else if (std::string(options_keys[i]) == std::string("debug-data"))
+ {
+ optimizerOptions.m_Debug = *options_values[i] != '0';
+ }
+ // Process memory-import
+ else if (std::string(options_keys[i]) == std::string("memory-import"))
+ {
+ optimizerOptions.m_ImportEnabled = *options_values[i] != '0';
+ }
else
{
throw armnn::Exception("Unknown option for the ArmNN Delegate given: " + std::string(options_keys[i]));
}
}
+ options.SetOptimizerOptions(optimizerOptions);
delegate = TfLiteArmnnDelegateCreate(options);
}
catch (const std::exception& ex)
diff --git a/delegate/src/test/DelegateOptionsTest.cpp b/delegate/src/test/DelegateOptionsTest.cpp
index c623781301..23510c7777 100644
--- a/delegate/src/test/DelegateOptionsTest.cpp
+++ b/delegate/src/test/DelegateOptionsTest.cpp
@@ -25,8 +25,7 @@ TEST_CASE ("ArmnnDelegateOptimizerOptionsReduceFp32ToFp16")
// Enable ReduceFp32ToFp16
armnn::OptimizerOptions optimizerOptions(true, true, false, false);
- armnn::INetworkProperties networkProperties;
- armnnDelegate::DelegateOptions delegateOptions(backends, optimizerOptions, networkProperties);
+ armnnDelegate::DelegateOptions delegateOptions(backends, optimizerOptions);
DelegateOptionTest<float>(::tflite::TensorType_FLOAT32,
backends,
@@ -56,8 +55,7 @@ TEST_CASE ("ArmnnDelegateOptimizerOptionsDebug")
// Enable Debug
armnn::OptimizerOptions optimizerOptions(false, true, false, false);
- armnn::INetworkProperties networkProperties;
- armnnDelegate::DelegateOptions delegateOptions(backends, optimizerOptions, networkProperties);
+ armnnDelegate::DelegateOptions delegateOptions(backends, optimizerOptions);
DelegateOptionTest<float>(::tflite::TensorType_FLOAT32,
backends,
@@ -98,7 +96,6 @@ TEST_CASE ("ArmnnDelegateOptimizerOptionsDebugFunction")
armnn::INetworkProperties networkProperties;
armnnDelegate::DelegateOptions delegateOptions(backends,
optimizerOptions,
- networkProperties,
armnn::EmptyOptional(),
armnn::Optional<armnn::DebugCallbackFunction>(mockCallback));
@@ -136,11 +133,10 @@ TEST_CASE ("ArmnnDelegateOptimizerOptionsImport")
std::vector<int32_t> tensorShape { 1, 2, 2, 1 };
std::vector<uint8_t> inputData = { 1, 2, 3, 4 };
std::vector<uint8_t> divData = { 2, 2, 3, 4 };
- std::vector<uint8_t> expectedResult = { 1, 2, 2, 2};
+ std::vector<uint8_t> expectedResult = { 1, 2, 2, 2 };
armnn::OptimizerOptions optimizerOptions(false, false, false, true);
- armnn::INetworkProperties networkProperties(true, true);
- armnnDelegate::DelegateOptions delegateOptions(backends, optimizerOptions, networkProperties);
+ armnnDelegate::DelegateOptions delegateOptions(backends, optimizerOptions);
DelegateOptionTest<uint8_t>(::tflite::TensorType_UINT8,
backends,