diff options
author | Sadik Armagan <sadik.armagan@arm.com> | 2022-08-16 12:17:24 +0100 |
---|---|---|
committer | Nikhil Raj <nikhil.raj@arm.com> | 2022-08-29 10:12:44 +0100 |
commit | ca565c1b04b767abfc13a59146680663a3ea4008 (patch) | |
tree | 58b260768fe8cb690f740ece44fca9c415620d7f /delegate/src/test/DelegateOptionsTest.cpp | |
parent | 514d16b434102a4a7807548745af301baab13b6b (diff) | |
download | armnn-ca565c1b04b767abfc13a59146680663a3ea4008.tar.gz |
IVGCVSW-6603 'Add a no fallback mode to the TfLite Delegate'
* Added disable-tflite-runtime-fallback option to armnn_delegate
* Updated armnn_delegate version
Signed-off-by: Sadik Armagan <sadik.armagan@arm.com>
Change-Id: I449b16404d3ffe98e6dac52a43e7c25225addd73
Diffstat (limited to 'delegate/src/test/DelegateOptionsTest.cpp')
-rw-r--r-- | delegate/src/test/DelegateOptionsTest.cpp | 74 |
1 files changed, 73 insertions, 1 deletions
diff --git a/delegate/src/test/DelegateOptionsTest.cpp b/delegate/src/test/DelegateOptionsTest.cpp index c9f1530968..50d3f78563 100644 --- a/delegate/src/test/DelegateOptionsTest.cpp +++ b/delegate/src/test/DelegateOptionsTest.cpp @@ -150,6 +150,79 @@ TEST_CASE ("ArmnnDelegateOptimizerOptionsImport") delegateOptions); } +TEST_CASE ("ArmnnDelegateStringParsingOptionDisableTfLiteRuntimeFallback") +{ + std::stringstream stringStream; + std::vector<std::string> keys { "backends", "debug-data", "disable-tflite-runtime-fallback"}; + std::vector<std::string> values { "CpuRef", "1", "1"}; + + std::vector<armnn::BackendId> backends = { armnn::Compute::CpuRef }; + std::vector<int32_t> tensorShape { 1, 2, 2, 1 }; + std::vector<float> inputData = { 0.1f, -2.1f, 3.0f, -4.6f }; + std::vector<float> expectedResult = { 1.0f, -2.0f, 3.0f, -4.0f }; + + // Create options_keys and options_values char array + size_t num_options = keys.size(); + std::unique_ptr<const char*> options_keys = + std::unique_ptr<const char*>(new const char*[num_options + 1]); + std::unique_ptr<const char*> options_values = + std::unique_ptr<const char*>(new const char*[num_options + 1]); + for (size_t i=0; i<num_options; ++i) + { + options_keys.get()[i] = keys[i].c_str(); + options_values.get()[i] = values[i].c_str(); + } + + StreamRedirector redirect(std::cout, stringStream.rdbuf()); + + armnnDelegate::DelegateOptions delegateOptions(options_keys.get(), options_values.get(), num_options, nullptr); + DelegateOptionNoFallbackTest<float>(::tflite::TensorType_FLOAT32, + backends, + tensorShape, + inputData, + expectedResult, + delegateOptions); + CHECK(stringStream.str().find("TfLiteArmnnDelegate: There are unsupported operators in the model") + != std::string::npos); +} + +TEST_CASE ("ArmnnDelegateStringParsingOptionEnableTfLiteRuntimeFallback") +{ + std::stringstream stringStream; + std::vector<std::string> keys { "backends", "debug-data", "disable-tflite-runtime-fallback"}; + std::vector<std::string> values { "CpuRef", "1", "0"}; + + std::vector<armnn::BackendId> backends = { armnn::Compute::CpuRef }; + std::vector<int32_t> tensorShape { 1, 2, 2, 1 }; + std::vector<float> inputData = { 0.1f, -2.1f, 3.0f, -4.6f }; + std::vector<float> expectedResult = { 1.0f, -2.0f, 3.0f, -4.0f }; + + // Create options_keys and options_values char array + size_t num_options = keys.size(); + std::unique_ptr<const char*> options_keys = + std::unique_ptr<const char*>(new const char*[num_options + 1]); + std::unique_ptr<const char*> options_values = + std::unique_ptr<const char*>(new const char*[num_options + 1]); + for (size_t i=0; i<num_options; ++i) + { + options_keys.get()[i] = keys[i].c_str(); + options_values.get()[i] = values[i].c_str(); + } + + StreamRedirector redirect(std::cout, stringStream.rdbuf()); + + armnnDelegate::DelegateOptions delegateOptions(options_keys.get(), options_values.get(), num_options, nullptr); + DelegateOptionNoFallbackTest<float>(::tflite::TensorType_FLOAT32, + backends, + tensorShape, + inputData, + expectedResult, + delegateOptions); + + CHECK(stringStream.str().find("TfLiteArmnnDelegate: There are unsupported operators in the model") + == std::string::npos); +} + } TEST_SUITE("DelegateOptions_CpuAccTests") @@ -307,7 +380,6 @@ TEST_CASE ("ArmnnDelegateStringParsingOptionReduceFp32ToFp16") } } - } } // namespace armnnDelegate |