From ea835e7d199be0c89bf80611e1d88f47c271503b Mon Sep 17 00:00:00 2001 From: Jan Eilers Date: Wed, 21 Apr 2021 16:58:28 +0100 Subject: IVGCVSW-5826 Add per channel tests * with Conv2D for tflite parser and delegate * with TransposeConv for tflite parser Signed-off-by: Jan Eilers Change-Id: I8d1ed1f3388c6eace436d0e6fd5869451c6e7830 --- delegate/src/test/Convolution2dTest.cpp | 95 +++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) (limited to 'delegate') diff --git a/delegate/src/test/Convolution2dTest.cpp b/delegate/src/test/Convolution2dTest.cpp index 6f498ce22e..b2e5fad8df 100644 --- a/delegate/src/test/Convolution2dTest.cpp +++ b/delegate/src/test/Convolution2dTest.cpp @@ -222,6 +222,83 @@ void Conv2DWithBiasesRelu6Uint8Test(std::vector& backends) biasValues); } + +void Conv2DPerChannelInt8Test(std::vector& backends) +{ + // Set input data + std::vector inputShape { 1,4,4,2 }; + std::vector filterShape { 4,2,2,2 }; + std::vector biasShape { 4 }; + std::vector outputShape { 1,4,4,4 }; + + static std::vector inputValues = + { + -11, 40,-26, 11,-28, 8, 0, -8, + -10, 34, 47, 0,-33,-14, 28, 35, + 6,-28,-26, 8, 13, 33,-31,-41, + 31,-20,-31,-16, 8,-18,-44, 0 + }; + + std::vector filterScales = { 1.858268, 2.0, 1.992126, 1.905512 }; + int32_t filterQuantizationDim = 0; + std::vector filterValues = + { + 13,-44, 5,-14, 21,-45, 36,-25, + -42, -2, 24,-30,-31, 35, 43,-30, + -20, -5, 25, 17, 18, 20, 4,-46, + -49, 9, -3,-20, 46, 5, 7,-15 + }; + + std::vector biasValues = { 0,0,0,0 }; + std::vector biasScales = { 0.721445, 0.7764700055, 0.773414, 0.739787 }; + + std::vector expectedOutputValues = + { + -1, 9, 3, 5, 1, -1, 5, 9, + 2, 7, -1, 2, 2, 4, 5, 6, + 1, 1, 4, 4, 2, 0, -4, -3, + 0, 6, 12, 6, 3, 0, -1, -2, + 7, -4, 4, 4, 3, 6, 6, 2, + 0, -3, -1, 4, 4, 8, 3, 1, + 5, 0, 0, 1, 4, 7, 4, 6, + 4, 0, 1, 2, 2, 7, 5, 7 + }; + float outputQuantScale = 401.960785f; + int outputQuantOffset = 3; + float inputQuantScale = 0.388235f; + int inputQuantOffset = 1; + + tflite::Padding padding = tflite::Padding_SAME; + + ConvolutionTest(tflite::BuiltinOperator_CONV_2D, + ::tflite::TensorType_INT8, + 1, // strideX + 1, // strideY + 1, // dilationX + 1, // dilationY + padding, + tflite::ActivationFunctionType_NONE, + backends, + inputShape, + filterShape, + outputShape, + inputValues, + filterValues, + expectedOutputValues, + biasShape, + biasValues, + biasScales, + {0,0,0,0}, + filterScales, + {0,0,0,0}, + outputQuantScale, + outputQuantOffset, + inputQuantScale, + inputQuantOffset, + 1, // depth_multiplier is ignored for conv2d value doesn't matter + filterQuantizationDim); +} + TEST_SUITE("Convolution2dTest_CpuRefTests") { @@ -237,6 +314,12 @@ TEST_CASE ("Conv2DWithBiases_Int8_CpuRef_Test") Conv2DWithBiasesInt8Test(backends); } +TEST_CASE ("Conv2DPerChannel_Int8_CpuRef_Test") +{ + std::vector backends = {armnn::Compute::CpuRef}; + Conv2DPerChannelInt8Test(backends); +} + } //End of TEST_SUITE("Convolution2dTest_CpuRef") TEST_SUITE("Convolution2dTest_CpuAccTests") @@ -254,6 +337,12 @@ std::vector backends = {armnn::Compute::CpuAcc}; Conv2DWithBiasesInt8Test(backends); } +TEST_CASE ("Conv2DPerChannel_Int8_CpuAcc_Test") +{ + std::vector backends = {armnn::Compute::CpuAcc}; + Conv2DPerChannelInt8Test(backends); +} + } //End of TEST_SUITE("Convolution2dTest_CpuAcc") TEST_SUITE("Convolution2dTest_GpuAccTests") @@ -271,6 +360,12 @@ std::vector backends = {armnn::Compute::GpuAcc}; Conv2DWithBiasesInt8Test(backends); } +TEST_CASE ("Conv2DPerChannel_Int8_GpuAcc_Test") +{ + std::vector backends = {armnn::Compute::GpuAcc}; + Conv2DPerChannelInt8Test(backends); +} + } //End of TEST_SUITE("Convolution2dTest_GpuAcc") void TransposeConvInt8Test(std::vector& backends) -- cgit v1.2.1