diff options
author | Ryan OShea <ryan.oshea3@arm.com> | 2022-11-07 16:20:48 +0000 |
---|---|---|
committer | ryan.oshea3 <ryan.oshea3@arm.com> | 2022-11-16 15:22:50 +0000 |
commit | 31441595009182c985dacbedc70c41ee6664d070 (patch) | |
tree | 248a85295aeff4022c9b395fc97748b0a0aa6b35 /delegate | |
parent | bd18eab07a8f30492de1e462b1815189014cb8d5 (diff) | |
download | armnn-31441595009182c985dacbedc70c41ee6664d070.tar.gz |
IVGCVSW-7214 Disable BF16-Turbo-Mode and remove conversion layers
- Remove Bf16ToFp32 Conversion Layer
- Remove Fp32ToBf16 Conversion Layer
- Remove B16 Conversion tests
* Throw exception if m_ReduceFp32ToBf16 optimzer option is set to true
* Provide comments to enable fast math in order to use bf16
* Update docs to inform users to enable fast math for bf16
Execute Network Changes
* Require bf16_turbo_mode to also have fast_math_enabled set to true
- Remove setting m_ReduceFp32ToBf16 optimizer option
Signed-off-by: Ryan OShea <ryan.oshea3@arm.com>
Change-Id: Ibaa6da9d29c96a1ce32ff5196b0847fde9f04a1c
Diffstat (limited to 'delegate')
-rw-r--r-- | delegate/include/DelegateOptions.hpp | 2 | ||||
-rw-r--r-- | delegate/python/test/test_external_delegate.py | 33 | ||||
-rw-r--r-- | delegate/src/DelegateOptions.cpp | 5 | ||||
-rw-r--r-- | delegate/src/test/DelegateOptionsTest.cpp | 13 | ||||
-rw-r--r-- | delegate/src/test/DelegateOptionsTestHelper.hpp | 89 |
5 files changed, 1 insertions, 141 deletions
diff --git a/delegate/include/DelegateOptions.hpp b/delegate/include/DelegateOptions.hpp index 2b0107e834..4f157db73b 100644 --- a/delegate/include/DelegateOptions.hpp +++ b/delegate/include/DelegateOptions.hpp @@ -113,7 +113,7 @@ public: * * Option key: "reduce-fp32-to-bf16" \n * Possible values: ["true"/"false"] \n - * Description: Reduce Fp32 data to Bf16 for faster processing + * Description: This option is currently ignored. Please enable Fast Math in the CpuAcc or GpuAcc backends. * * Option key: "debug-data" \n * Possible values: ["true"/"false"] \n diff --git a/delegate/python/test/test_external_delegate.py b/delegate/python/test/test_external_delegate.py index a8dd8e6d3e..fe58d57e90 100644 --- a/delegate/python/test/test_external_delegate.py +++ b/delegate/python/test/test_external_delegate.py @@ -218,39 +218,6 @@ def test_external_delegate_options_fp32_to_fp16(capfd, delegate_dir, test_data_f assert "convert_fp32_to_fp16" in captured.out assert "convert_fp16_to_fp32" in captured.out -def test_external_delegate_options_fp32_to_bf16(capfd, delegate_dir, test_data_folder): - # create armnn delegate with reduce-fp32-to-bf16 option - armnn_delegate = tflite.load_delegate(delegate_dir, options = {"backends": "CpuRef", - "debug-data": "1", - "reduce-fp32-to-bf16": "1"}) - - model_file_name = "conv2d.tflite" - - inputShape = [ 1, 5, 5, 1 ] - outputShape = [ 1, 3, 3, 1 ] - - inputValues = [ 1, 5, 2, 3, 5, - 8, 7, 3, 6, 3, - 3, 3, 9, 1, 9, - 4, 1, 8, 1, 3, - 6, 8, 1, 9, 2 ] - - expectedResult = [ 28, 38, 29, - 96, 104, 53, - 31, 55, 24 ] - - input = np.array(inputValues, dtype=np.float32).reshape(inputShape) - expected_output = np.array(expectedResult, dtype=np.float32).reshape(outputShape) - - # run the inference - armnn_outputs = run_inference(test_data_folder, model_file_name, [input], [armnn_delegate]) - - # check results - compare_outputs(armnn_outputs, [expected_output]) - - captured = capfd.readouterr() - assert "convert_fp32_to_bf16" in captured.out - def test_external_delegate_options_memory_import(delegate_dir, test_data_folder): # create armnn delegate with memory-import option armnn_delegate = tflite.load_delegate(delegate_dir, options = {"backends": "CpuAcc,CpuRef", diff --git a/delegate/src/DelegateOptions.cpp b/delegate/src/DelegateOptions.cpp index a55a579333..bb1edab009 100644 --- a/delegate/src/DelegateOptions.cpp +++ b/delegate/src/DelegateOptions.cpp @@ -146,11 +146,6 @@ DelegateOptions::DelegateOptions(char const* const* options_keys, { optimizerOptions.m_ReduceFp32ToFp16 = armnn::stringUtils::StringToBool(options_values[i]); } - // Process reduce-fp32-to-bf16 option - else if (std::string(options_keys[i]) == std::string("reduce-fp32-to-bf16")) - { - optimizerOptions.m_ReduceFp32ToBf16 = armnn::stringUtils::StringToBool(options_values[i]); - } // Process debug-data else if (std::string(options_keys[i]) == std::string("debug-data")) { diff --git a/delegate/src/test/DelegateOptionsTest.cpp b/delegate/src/test/DelegateOptionsTest.cpp index 50d3f78563..98323131f9 100644 --- a/delegate/src/test/DelegateOptionsTest.cpp +++ b/delegate/src/test/DelegateOptionsTest.cpp @@ -116,19 +116,6 @@ TEST_CASE ("ArmnnDelegateOptimizerOptionsDebugFunction") CHECK(callback); } -TEST_CASE ("ArmnnDelegateOptimizerOptionsReduceFp32ToBf16") -{ - std::stringstream ss; - { - StreamRedirector redirect(std::cout, ss.rdbuf()); - - ReduceFp32ToBf16TestImpl(); - } - - // ReduceFp32ToBf16 option is enabled - CHECK(ss.str().find("convert_fp32_to_bf16") != std::string::npos); -} - TEST_CASE ("ArmnnDelegateOptimizerOptionsImport") { std::vector<armnn::BackendId> backends = { armnn::Compute::CpuAcc, armnn::Compute::CpuRef }; diff --git a/delegate/src/test/DelegateOptionsTestHelper.hpp b/delegate/src/test/DelegateOptionsTestHelper.hpp index 87bf0d6c3d..7e147de31f 100644 --- a/delegate/src/test/DelegateOptionsTestHelper.hpp +++ b/delegate/src/test/DelegateOptionsTestHelper.hpp @@ -219,95 +219,6 @@ std::vector<char> CreateCeilTfLiteModel(tflite::TensorType tensorType, flatBufferBuilder.GetBufferPointer() + flatBufferBuilder.GetSize()); } -void ReduceFp32ToBf16TestImpl() -{ - using namespace tflite; - // Set input data - std::vector<int32_t> inputShape{ 1, 5, 5, 1 }; - std::vector<int32_t> filterShape{ 1, 3, 3, 1 }; - std::vector<int32_t> biasShape{ 1 }; - std::vector<int32_t> outputShape{ 1, 3, 3, 1 }; - - std::vector<float> inputValues = - { - 1, 5, 2, 3, 5, - 8, 7, 3, 6, 3, - 3, 3, 9, 1, 9, - 4, 1, 8, 1, 3, - 6, 8, 1, 9, 2 - }; - - std::vector<float> filterValues = - { - 4, 5, 6, - 0, 0, 0, - 3, 2, 1 - }; - - std::vector<float> biasValues = { 5 }; - - std::vector<float> expectedResult = - { - 28, 38, 29, - 96, 104, 53, - 31, 55, 24 - }; - - tflite::Padding padding = Padding_SAME; - - std::vector<char> modelBuffer; - modelBuffer = CreateConv2dTfLiteModel<float>(BuiltinOperator_CONV_2D, - ::tflite::TensorType_FLOAT32, - 2, - 2, - 1, - 1, - padding, - ActivationFunctionType_NONE, - inputShape, - filterShape, - biasShape, - outputShape, - filterValues, - biasValues); - - - const Model* tfLiteModel = GetModel(modelBuffer.data()); - // Create TfLite Interpreters - std::unique_ptr<Interpreter> armnnDelegateInterpreter; - CHECK(InterpreterBuilder(tfLiteModel, ::tflite::ops::builtin::BuiltinOpResolver()) - (&armnnDelegateInterpreter) == kTfLiteOk); - CHECK(armnnDelegateInterpreter != nullptr); - CHECK(armnnDelegateInterpreter->AllocateTensors() == kTfLiteOk); - - // Create the Armnn Delegate - std::vector<armnn::BackendId> backends = {armnn::Compute::CpuRef}; - std::vector<armnn::BackendOptions> backendOptions; - - // Enable debug with BF16 enabled - armnn::OptimizerOptions optimizerOptions(false, true, true, false); - - armnnDelegate::DelegateOptions delegateOptions(backends, optimizerOptions); - std::unique_ptr<TfLiteDelegate, decltype(&armnnDelegate::TfLiteArmnnDelegateDelete)> - theArmnnDelegate(armnnDelegate::TfLiteArmnnDelegateCreate(delegateOptions), - armnnDelegate::TfLiteArmnnDelegateDelete); - CHECK(theArmnnDelegate != nullptr); - // Modify armnnDelegateInterpreter to use armnnDelegate - CHECK(armnnDelegateInterpreter->ModifyGraphWithDelegate(theArmnnDelegate.get()) == kTfLiteOk); - - // Set input data - armnnDelegate::FillInput(armnnDelegateInterpreter, 0, inputValues); - - // Run EnqueueWorkload - CHECK(armnnDelegateInterpreter->Invoke() == kTfLiteOk); - - // Compare output data - auto armnnDelegateOutputId = armnnDelegateInterpreter->outputs()[0]; - auto armnnDelegateOutputData = armnnDelegateInterpreter->typed_tensor<float>(armnnDelegateOutputId); - armnnDelegate::CompareData(expectedResult.data(), armnnDelegateOutputData, expectedResult.size()); - armnnDelegateInterpreter.reset(nullptr); -} - template <typename T> void DelegateOptionTest(tflite::TensorType tensorType, const std::vector<armnn::BackendId>& backends, |