From 0ec008761ab26110dcb108d544be4040a14fd403 Mon Sep 17 00:00:00 2001 From: John Mcloughlin Date: Mon, 15 May 2023 17:03:49 +0100 Subject: IVGCVSW-7400 POW IVGCVSW-7278 SQUARED_DIFFERENCE. * Added 2 new operators as ElementWiseBinary ops * Ref End to End and unit tests * Serialize and Deserialize tests * Delegate and Opaque Delegate tests * TfLite Parser tests Signed-off-by: John Mcloughlin Change-Id: I537158127f602f0c41ca0402aa31655cd3bd4281 --- delegate/test/ElementwiseBinaryTest.cpp | 56 +++++++++++++++++++++++++++ delegate/test/ElementwiseBinaryTestHelper.hpp | 12 ++++++ 2 files changed, 68 insertions(+) (limited to 'delegate/test') diff --git a/delegate/test/ElementwiseBinaryTest.cpp b/delegate/test/ElementwiseBinaryTest.cpp index effed03e5e..2f22e7d1b1 100644 --- a/delegate/test/ElementwiseBinaryTest.cpp +++ b/delegate/test/ElementwiseBinaryTest.cpp @@ -699,6 +699,50 @@ void SubFP32Test(std::vector& backends) expectedOutputValues); } +void PowerFP32Test(std::vector& backends) +{ + std::vector input0Shape { 1, 1, 2, 2 }; + std::vector input1Shape { 1, 1, 2, 2 }; + std::vector expectedOutputShape { 1, 1, 2, 2 }; + + std::vector input0Values = { 1, 3, 3, -7 }; + std::vector input1Values = { 1, 1, 0, 2 }; + std::vector expectedOutputValues = { 1, 3, 1, 49 }; + + ElementwiseBinaryTest(tflite::BuiltinOperator_POW, + tflite::ActivationFunctionType_NONE, + ::tflite::TensorType_FLOAT32, + backends, + input0Shape, + input1Shape, + expectedOutputShape, + input0Values, + input1Values, + expectedOutputValues); +} + +void SqDiffFP32Test(std::vector& backends) +{ + std::vector input0Shape { 1, 1, 2, 2 }; + std::vector input1Shape { 1, 1, 2, 2 }; + std::vector expectedOutputShape { 1, 1, 2, 2 }; + + std::vector input0Values = { 1, 3, 3, -7 }; + std::vector input1Values = { 1, -1, 0, -2 }; + std::vector expectedOutputValues = { 0, 16, 9, 25 }; + + ElementwiseBinaryTest(tflite::BuiltinOperator_SQUARED_DIFFERENCE, + tflite::ActivationFunctionType_NONE, + ::tflite::TensorType_FLOAT32, + backends, + input0Shape, + input1Shape, + expectedOutputShape, + input0Values, + input1Values, + expectedOutputValues); +} + void SubBroadcastTest(std::vector& backends) { std::vector input0Shape { 1, 1, 2, 2 }; @@ -1131,6 +1175,18 @@ TEST_CASE ("SUB_UINT8_CpuRef_Test") SubUint8Test(backends); } +TEST_CASE ("SqDiffFP32_CpuRef_Test") +{ + std::vector backends = { armnn::Compute::CpuRef }; + SqDiffFP32Test(backends); +} + +TEST_CASE ("PowerFP32_CpuRef_Test") +{ + std::vector backends = { armnn::Compute::CpuRef }; + PowerFP32Test(backends); +} + } // TEST_SUITE("ElementwiseBinary_CpuRefTests") } // namespace armnnDelegate diff --git a/delegate/test/ElementwiseBinaryTestHelper.hpp b/delegate/test/ElementwiseBinaryTestHelper.hpp index fa9cbb881e..fc7549161c 100644 --- a/delegate/test/ElementwiseBinaryTestHelper.hpp +++ b/delegate/test/ElementwiseBinaryTestHelper.hpp @@ -124,6 +124,18 @@ std::vector CreateElementwiseBinaryTfLiteModel(tflite::BuiltinOperator bin operatorBuiltinOptions = CreateSubOptions(flatBufferBuilder, activationType).Union(); break; } + case BuiltinOperator_POW: + { + operatorBuiltinOptionsType = BuiltinOptions_PowOptions; + operatorBuiltinOptions = CreatePowOptions(flatBufferBuilder).Union(); + break; + } + case BuiltinOperator_SQUARED_DIFFERENCE: + { + operatorBuiltinOptionsType = BuiltinOptions_SquaredDifferenceOptions; + operatorBuiltinOptions = CreateSquaredDifferenceOptions(flatBufferBuilder).Union(); + break; + } case BuiltinOperator_FLOOR_DIV: { operatorBuiltinOptionsType = tflite::BuiltinOptions_FloorDivOptions; -- cgit v1.2.1