From d6a9dee3fe584921d24a264176468898d38a6202 Mon Sep 17 00:00:00 2001 From: Matthew Jackson Date: Mon, 22 Jul 2019 13:53:24 +0100 Subject: IVGCVSW-3368 Add reference support for depthwise multiplier > 3 * Remove multiplier check in TfLite parser * Add reference unit test for depthwise multipler of 64, as in DeepSpeaker Signed-off-by: Matthew Jackson Change-Id: I787339ab4c4d269333985353d191202d070906ba --- src/armnnTfLiteParser/TfLiteParser.cpp | 3 +-- src/backends/backendsCommon/test/LayerTests.cpp | 32 +++++++++++++++++++++++++ src/backends/backendsCommon/test/LayerTests.hpp | 4 ++++ src/backends/reference/test/RefLayerTests.cpp | 2 ++ 4 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/armnnTfLiteParser/TfLiteParser.cpp b/src/armnnTfLiteParser/TfLiteParser.cpp index 04fa6b1947..f345d4a6e1 100644 --- a/src/armnnTfLiteParser/TfLiteParser.cpp +++ b/src/armnnTfLiteParser/TfLiteParser.cpp @@ -791,8 +791,7 @@ void TfLiteParser::ParseDepthwiseConv2D(size_t subgraphIndex, size_t operatorInd desc.m_StrideX = CHECKED_NON_NEGATIVE(options->stride_w); desc.m_StrideY = CHECKED_NON_NEGATIVE(options->stride_h); desc.m_DataLayout = armnn::DataLayout::NHWC; - // ACL only supports a depth (channel) multiplier of {1,2,3}, it is not currently stored in the descriptor - CHECK_VALID_SIZE(CHECKED_NON_NEGATIVE(options->depth_multiplier), 1,2,3 ); + CHECKED_NON_NEGATIVE(options->depth_multiplier); auto inputs = GetInputs(m_Model, subgraphIndex, operatorIndex); CHECK_VALID_SIZE(inputs.size(), 2, 3); diff --git a/src/backends/backendsCommon/test/LayerTests.cpp b/src/backends/backendsCommon/test/LayerTests.cpp index 03ab37dd46..d6e0e879fd 100644 --- a/src/backends/backendsCommon/test/LayerTests.cpp +++ b/src/backends/backendsCommon/test/LayerTests.cpp @@ -1498,6 +1498,38 @@ LayerTestResult DepthwiseConvolution2dDepthMul1Test( workloadFactory, memoryManager, 0.0f, 0, biasEnabled, layout); } +LayerTestResult DepthwiseConvolution2dDepthMul64Test( + armnn::IWorkloadFactory& workloadFactory, + const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) +{ + armnn::TensorInfo inputTensorInfo({ 1, 1, 2, 2 }, armnn::DataType::Float32); + auto input = MakeTensor(inputTensorInfo, { 1.f, 2.f, 3.f, 4.f }); + + std::vector kernelData; + std::vector singleDepthKernel{ 1.f, -1.f, -1.f, 1.f }; + for (unsigned int i = 0; i < 64; ++i) + { + kernelData.insert(kernelData.end(), singleDepthKernel.begin(), singleDepthKernel.end()); + } + armnn::TensorInfo kernelTensorInfo({ 64, 1, 2, 2 }, armnn::DataType::Float32); + auto kernel = MakeTensor(kernelTensorInfo, kernelData); + + std::vector expectedOutputData(64, 0.f); + armnn::TensorInfo outputTensorInfo({ 1, 64, 1, 1 }, armnn::DataType::Float32); + auto expectedOutput = MakeTensor(outputTensorInfo, expectedOutputData); + + return DepthwiseConvolution2dTestImpl( + workloadFactory, + memoryManager, + input, + kernel, + boost::multi_array(), + expectedOutput, + 0.f, + 0, + armnn::DataLayout::NCHW); +} + LayerTestResult DepthwiseConvolution2dAsymmetricTest( armnn::IWorkloadFactory& workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, diff --git a/src/backends/backendsCommon/test/LayerTests.hpp b/src/backends/backendsCommon/test/LayerTests.hpp index 3db826f379..d99e3b4f3a 100644 --- a/src/backends/backendsCommon/test/LayerTests.hpp +++ b/src/backends/backendsCommon/test/LayerTests.hpp @@ -159,6 +159,10 @@ LayerTestResult DepthwiseConvolution2dDepthMul1Test( bool biasEnabled, const armnn::DataLayout layout); +LayerTestResult DepthwiseConvolution2dDepthMul64Test( + armnn::IWorkloadFactory& workloadFactory, + const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager); + LayerTestResult DepthwiseConvolution2dAsymmetricTest( armnn::IWorkloadFactory& workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, diff --git a/src/backends/reference/test/RefLayerTests.cpp b/src/backends/reference/test/RefLayerTests.cpp index 4f46d27883..8af42eaba2 100644 --- a/src/backends/reference/test/RefLayerTests.cpp +++ b/src/backends/reference/test/RefLayerTests.cpp @@ -267,6 +267,8 @@ ARMNN_AUTO_TEST_CASE(DepthwiseConvolution2dAsymmetricNhwc, ARMNN_AUTO_TEST_CASE(UnbiasedDepthwiseConvolution2dAsymmetricNhwc, DepthwiseConvolution2dAsymmetricTest, false, armnn::DataLayout::NHWC) +ARMNN_AUTO_TEST_CASE(DepthwiseConvolution2dDepthMul64, DepthwiseConvolution2dDepthMul64Test); + // Pooling //MaxPooling ARMNN_AUTO_TEST_CASE(SimpleMaxPooling2dSize2x2Stride2x2, SimpleMaxPooling2dSize2x2Stride2x2Test, false) -- cgit v1.2.1