diff options
author | Sadik Armagan <sadik.armagan@arm.com> | 2021-05-05 15:03:50 +0100 |
---|---|---|
committer | Kevin May <kevin.may@arm.com> | 2021-05-06 07:49:22 +0000 |
commit | f7ac72c85c90c61be14fff16c9c2ff638fa32c40 (patch) | |
tree | ac1455193dcbb3226aa612a3fdf87f913c0cd4fd /delegate/src/test/ElementwiseBinaryTest.cpp | |
parent | a18c70843189cbabf72f4e502bf35b5df2d359bf (diff) | |
download | armnn-f7ac72c85c90c61be14fff16c9c2ff638fa32c40.tar.gz |
IVGCVSW-5418 'ExecuteNetwork test for MobileBERT'
* Refactored the code for checking constant inputs.
* Added a unit test for ADD operator with constant input.
Signed-off-by: Sadik Armagan <sadik.armagan@arm.com>
Change-Id: Ie7207e5a1ce77ea305552859de32a66e07c68a6f
Diffstat (limited to 'delegate/src/test/ElementwiseBinaryTest.cpp')
-rw-r--r-- | delegate/src/test/ElementwiseBinaryTest.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/delegate/src/test/ElementwiseBinaryTest.cpp b/delegate/src/test/ElementwiseBinaryTest.cpp index cc447d9fc3..448b3e6fd9 100644 --- a/delegate/src/test/ElementwiseBinaryTest.cpp +++ b/delegate/src/test/ElementwiseBinaryTest.cpp @@ -129,6 +129,55 @@ void AddBroadcastTest(std::vector<armnn::BackendId>& backends) expectedOutputValues); } +void AddConstInputTest(std::vector<armnn::BackendId>& backends) +{ + std::vector<int32_t> input0Shape { 1, 3, 2, 1 }; + std::vector<int32_t> input1Shape { 1 }; + std::vector<int32_t> expectedOutputShape { 1, 3, 2, 1 }; + + std::vector<float> input0Values + { + 0.0f, + 1.0f, + + 2.0f, + 3.0f, + + 4.0f, + 5.0f, + }; + std::vector<float> input1Values + { + 0.5f + }; + // Set output data + std::vector<float> expectedOutputValues + { + 0.5f, + 1.5f, + + 2.5f, + 3.5f, + + 4.5f, + 5.5f, + }; + + ElementwiseBinaryTest<float>(tflite::BuiltinOperator_ADD, + tflite::ActivationFunctionType_NONE, + ::tflite::TensorType_FLOAT32, + backends, + input0Shape, + input1Shape, + expectedOutputShape, + input0Values, + input1Values, + expectedOutputValues, + 1.0f, + 0, + true); +} + void AddActivationTest(std::vector<armnn::BackendId>& backends) { std::vector<int32_t> input0Shape { 1, 2, 2, 1 }; @@ -913,6 +962,12 @@ TEST_CASE ("ADD_Broadcast_CpuRef_Test") AddBroadcastTest(backends); } +TEST_CASE ("ADD_Constant_Input_CpuRef_Test") +{ + std::vector<armnn::BackendId> backends = { armnn::Compute::CpuRef }; + AddConstInputTest(backends); +} + TEST_CASE ("ADD_Actiation_CpuRef_Test") { std::vector<armnn::BackendId> backends = { armnn::Compute::CpuRef }; |