From 0421e7f22d9ccd5d810b345731b766a96c841492 Mon Sep 17 00:00:00 2001 From: nikraj01 Date: Fri, 14 Jun 2019 09:40:34 +0100 Subject: IVGCVSW-3224 Add Uint8 support for Rsqrt Change-Id: I45598fc9b6d408b19d8d050e64c12b1d48535fa3 Signed-off-by: nikraj01 --- src/backends/backendsCommon/test/LayerTests.hpp | 133 ++++++++++++++---------- 1 file changed, 77 insertions(+), 56 deletions(-) (limited to 'src/backends/backendsCommon/test') diff --git a/src/backends/backendsCommon/test/LayerTests.hpp b/src/backends/backendsCommon/test/LayerTests.hpp index 8bbd0d47c8..8a5a61145c 100644 --- a/src/backends/backendsCommon/test/LayerTests.hpp +++ b/src/backends/backendsCommon/test/LayerTests.hpp @@ -887,8 +887,8 @@ LayerTestResult Rsqrt2dTestCommon( const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, const armnn::TensorInfo inputTensorInfo, const armnn::TensorInfo outputTensorInfo, - std::vector inputValues, - std::vector expectedOutputValues); + const std::vector& inputValues, + const std::vector& expectedOutputValues); template> LayerTestResult Rsqrt2dTest( @@ -1941,19 +1941,21 @@ std::vector ConvertToDataType(const std::vector& input, return output; } -template +template LayerTestResult Rsqrt2dTestCommon( armnn::IWorkloadFactory& workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, const armnn::TensorInfo inputTensorInfo, const armnn::TensorInfo outputTensorInfo, - std::vector inputValues, - std::vector expectedOutputValues) + const std::vector& inputValues, + const std::vector& expectedOutputValues) { - auto inputTensor = MakeTensor(inputTensorInfo, std::vector(inputValues)); + auto inputTensor = MakeTensor(inputTensorInfo, ConvertToDataType(inputValues,inputTensorInfo)); LayerTestResult result(outputTensorInfo); - result.outputExpected = MakeTensor(outputTensorInfo, std::vector(expectedOutputValues)); + + result.outputExpected = MakeTensor(outputTensorInfo, + ConvertToDataType(expectedOutputValues,outputTensorInfo)); std::unique_ptr inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo); std::unique_ptr outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); @@ -1988,22 +1990,27 @@ LayerTestResult Rsqrt2dTest( const armnn::TensorShape inputShape{ 2, 2 }; const armnn::TensorShape outputShape{ 2, 2 }; - const armnn::TensorInfo inputTensorInfo(inputShape, ArmnnType); - const armnn::TensorInfo outputTensorInfo(outputShape, ArmnnType); + armnn::TensorInfo inputTensorInfo(inputShape, ArmnnType); + inputTensorInfo.SetQuantizationScale(0.1f); + inputTensorInfo.SetQuantizationOffset(0); + + armnn::TensorInfo outputTensorInfo(outputShape, ArmnnType); + outputTensorInfo.SetQuantizationScale(0.1f); + outputTensorInfo.SetQuantizationOffset(0); - std::vector inputValues - { - 1.f, 4.f, - 16.f, 25.f - }; + std::vector inputValues + { + 1.f, 4.f, + 16.f, 25.f + }; - std::vector expectedOutputValues - { - 1.f, 0.5f, - 0.25f, 0.2f - }; + std::vector expectedOutputValues + { + 1.f, 0.5f, + 0.25f, 0.2f + }; - return Rsqrt2dTestCommon(workloadFactory, memoryManager, + return Rsqrt2dTestCommon(workloadFactory, memoryManager, inputTensorInfo, outputTensorInfo, inputValues, expectedOutputValues); } @@ -2016,25 +2023,31 @@ LayerTestResult Rsqrt3dTest( const armnn::TensorShape inputShape{ 3, 1, 2 }; const armnn::TensorShape outputShape{ 3, 1, 2 }; - const armnn::TensorInfo inputTensorInfo(inputShape, ArmnnType); - const armnn::TensorInfo outputTensorInfo(outputShape, ArmnnType); + armnn::TensorInfo inputTensorInfo(inputShape, ArmnnType); + inputTensorInfo.SetQuantizationScale(0.1f); + inputTensorInfo.SetQuantizationOffset(0); - std::vector inputValues - { - 1.f, 4.f, 16.f, - 25.f, 64.f, 100.f - }; + armnn::TensorInfo outputTensorInfo(outputShape, ArmnnType); + outputTensorInfo.SetQuantizationScale(0.1f); + outputTensorInfo.SetQuantizationOffset(0); - std::vector expectedOutputValues - { - 1.f, 0.5f, 0.25f, - 0.2f, 0.125f, 0.1f - }; + std::vector inputValues + { + 1.f, 4.f, 16.f, + 25.f, 64.f, 100.f + }; - auto inputTensor = MakeTensor(inputTensorInfo, std::vector(inputValues)); + std::vector expectedOutputValues + { + 1.f, 0.5f, 0.25f, + 0.2f, 0.125f, 0.1f + }; + + auto inputTensor = MakeTensor(inputTensorInfo, ConvertToDataType(inputValues,inputTensorInfo)); LayerTestResult result(outputTensorInfo); - result.outputExpected = MakeTensor(outputTensorInfo, std::vector(expectedOutputValues)); + result.outputExpected = MakeTensor(outputTensorInfo, + ConvertToDataType(expectedOutputValues,outputTensorInfo)); std::unique_ptr inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo); std::unique_ptr outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); @@ -2069,20 +2082,23 @@ LayerTestResult RsqrtZeroTest( const armnn::TensorShape inputShape{ 1, 2 }; const armnn::TensorShape outputShape{ 1, 2 }; - const armnn::TensorInfo inputTensorInfo(inputShape, ArmnnType); - const armnn::TensorInfo outputTensorInfo(outputShape, ArmnnType); + armnn::TensorInfo inputTensorInfo(inputShape, ArmnnType); + inputTensorInfo.SetQuantizationScale(0.1f); + + armnn::TensorInfo outputTensorInfo(outputShape, ArmnnType); + outputTensorInfo.SetQuantizationScale(0.1f); - std::vector inputValues - { - 0.f, -0.f - }; + std::vector inputValues + { + 0.f, -0.f + }; - std::vector expectedOutputValues - { - INFINITY, -INFINITY - }; + std::vector expectedOutputValues + { + INFINITY, -INFINITY + }; - return Rsqrt2dTestCommon(workloadFactory, memoryManager, + return Rsqrt2dTestCommon(workloadFactory, memoryManager, inputTensorInfo, outputTensorInfo, inputValues, expectedOutputValues); } @@ -2095,20 +2111,25 @@ LayerTestResult RsqrtNegativeTest( const armnn::TensorShape inputShape{ 1, 2 }; const armnn::TensorShape outputShape{ 1, 2 }; - const armnn::TensorInfo inputTensorInfo(inputShape, ArmnnType); - const armnn::TensorInfo outputTensorInfo(outputShape, ArmnnType); + armnn::TensorInfo inputTensorInfo(inputShape, ArmnnType); + inputTensorInfo.SetQuantizationScale(0.1f); + inputTensorInfo.SetQuantizationOffset(0); - std::vector inputValues - { - -25.f, -16.f - }; + armnn::TensorInfo outputTensorInfo(outputShape, ArmnnType); + outputTensorInfo.SetQuantizationScale(0.1f); + outputTensorInfo.SetQuantizationOffset(0); - std::vector expectedOutputValues - { - -NAN, -NAN - }; + std::vector inputValues + { + -25.f, -16.f + }; + + std::vector expectedOutputValues + { + -NAN, -NAN + }; - return Rsqrt2dTestCommon(workloadFactory, memoryManager, + return Rsqrt2dTestCommon(workloadFactory, memoryManager, inputTensorInfo, outputTensorInfo, inputValues, expectedOutputValues); } -- cgit v1.2.1