From 248683fef73807b49e5a58fbd0428900b7e9cfb9 Mon Sep 17 00:00:00 2001 From: nikraj01 Date: Wed, 29 May 2019 16:46:50 +0100 Subject: [PATCH] IVGCVSW-3173 Extend reference softmax workload to support qsymm16 Change-Id: I9ad5a04368a4587588d733ac36ad157f79b6c432 Signed-off-by: nikraj01 --- src/backends/backendsCommon/WorkloadData.cpp | 16 +++++++++++++++ src/backends/backendsCommon/test/LayerTests.cpp | 24 ++++++++++++++++++++++ src/backends/backendsCommon/test/LayerTests.hpp | 15 ++++++++++++++ src/backends/reference/RefLayerSupport.cpp | 23 ++++++++++++++++----- .../reference/test/RefCreateWorkloadTests.cpp | 5 +++++ src/backends/reference/test/RefLayerTests.cpp | 4 ++++ 6 files changed, 82 insertions(+), 5 deletions(-) diff --git a/src/backends/backendsCommon/WorkloadData.cpp b/src/backends/backendsCommon/WorkloadData.cpp index 96e83c2..e8e10d9 100644 --- a/src/backends/backendsCommon/WorkloadData.cpp +++ b/src/backends/backendsCommon/WorkloadData.cpp @@ -327,6 +327,22 @@ void SoftmaxQueueDescriptor::Validate(const WorkloadInfo& workloadInfo) const "SoftmaxQueueDescriptor", "input", "output"); + + std::vector supportedTypes = + { + DataType::Float16, + DataType::Float32, + DataType::QuantisedAsymm8, + DataType::QuantisedSymm16 + }; + + ValidateDataTypes(workloadInfo.m_InputTensorInfos[0], + supportedTypes, + "SoftmaxQueueDescriptor"); + + ValidateDataTypes(workloadInfo.m_OutputTensorInfos[0], + {workloadInfo.m_InputTensorInfos[0].GetDataType()}, + "SoftmaxQueueDescriptor"); } //--------------------------------------------------------------- diff --git a/src/backends/backendsCommon/test/LayerTests.cpp b/src/backends/backendsCommon/test/LayerTests.cpp index bc8e13d..de3c857 100644 --- a/src/backends/backendsCommon/test/LayerTests.cpp +++ b/src/backends/backendsCommon/test/LayerTests.cpp @@ -1070,6 +1070,30 @@ LayerTestResult Simple4dSoftmaxUint8Test( return Simple4dSoftmaxTestImpl(workloadFactory, memoryManager, beta); } +LayerTestResult SimpleSoftmaxUint16Test( + armnn::IWorkloadFactory& workloadFactory, + const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, + float beta) +{ + return SimpleSoftmaxTestImpl(workloadFactory, memoryManager, beta); +} + +LayerTestResult Simple3dSoftmaxUint16Test( + armnn::IWorkloadFactory& workloadFactory, + const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, + float beta) +{ + return Simple3dSoftmaxTestImpl(workloadFactory, memoryManager, beta); +} + +LayerTestResult Simple4dSoftmaxUint16Test( + armnn::IWorkloadFactory& workloadFactory, + const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, + float beta) +{ + return Simple4dSoftmaxTestImpl(workloadFactory, memoryManager, beta); +} + LayerTestResult CompareNormalizationTest( 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 edb7045..893252b 100644 --- a/src/backends/backendsCommon/test/LayerTests.hpp +++ b/src/backends/backendsCommon/test/LayerTests.hpp @@ -369,6 +369,21 @@ LayerTestResult Simple4dSoftmaxUint8Test( const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, float beta); +LayerTestResult SimpleSoftmaxUint16Test( + armnn::IWorkloadFactory& workloadFactory, + const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, + float beta); + +LayerTestResult Simple3dSoftmaxUint16Test( + armnn::IWorkloadFactory& workloadFactory, + const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, + float beta); + +LayerTestResult Simple4dSoftmaxUint16Test( + armnn::IWorkloadFactory& workloadFactory, + const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, + float beta); + LayerTestResult SimpleSigmoidTest( armnn::IWorkloadFactory& workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager); diff --git a/src/backends/reference/RefLayerSupport.cpp b/src/backends/reference/RefLayerSupport.cpp index a9cddfd..e4bc9bf 100644 --- a/src/backends/reference/RefLayerSupport.cpp +++ b/src/backends/reference/RefLayerSupport.cpp @@ -1060,11 +1060,24 @@ bool RefLayerSupport::IsSoftmaxSupported(const TensorInfo& input, Optional reasonIfUnsupported) const { ignore_unused(output); - ignore_unused(descriptor); - return IsSupportedForDataTypeRef(reasonIfUnsupported, - input.GetDataType(), - &TrueFunc<>, - &TrueFunc<>); + bool supported = true; + std::array supportedTypes = + { + DataType::Float32, + DataType::QuantisedAsymm8, + DataType::QuantisedSymm16 + }; + + supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported, + "Reference concatenation: output type not supported"); + + supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported, + "Reference concatenation: input type not supported"); + + supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported, + "Reference concatenation: input type not supported"); + + return supported; } bool RefLayerSupport::IsSpaceToBatchNdSupported(const TensorInfo& input, diff --git a/src/backends/reference/test/RefCreateWorkloadTests.cpp b/src/backends/reference/test/RefCreateWorkloadTests.cpp index fef2567..78083fa 100644 --- a/src/backends/reference/test/RefCreateWorkloadTests.cpp +++ b/src/backends/reference/test/RefCreateWorkloadTests.cpp @@ -441,6 +441,11 @@ BOOST_AUTO_TEST_CASE(CreateSoftmaxQuantisedAsymm8Workload) RefCreateSoftmaxWorkloadTest(); } +BOOST_AUTO_TEST_CASE(CreateSoftmaxQuantisedSymm16Workload) +{ + RefCreateSoftmaxWorkloadTest(); +} + template static void RefCreateSplitterWorkloadTest() { diff --git a/src/backends/reference/test/RefLayerTests.cpp b/src/backends/reference/test/RefLayerTests.cpp index a78b5aa..522d673 100644 --- a/src/backends/reference/test/RefLayerTests.cpp +++ b/src/backends/reference/test/RefLayerTests.cpp @@ -200,6 +200,10 @@ ARMNN_AUTO_TEST_CASE(Simple3dSoftmaxUint8, Simple3dSoftmaxUint8Test, 1.0f) ARMNN_AUTO_TEST_CASE(Simple4dSoftmax, Simple4dSoftmaxTest, 1.0f) ARMNN_AUTO_TEST_CASE(Simple4dSoftmaxUint8, Simple4dSoftmaxUint8Test, 1.0f) +ARMNN_AUTO_TEST_CASE(SimpleSoftmaxUint16, SimpleSoftmaxUint16Test, 1.0f) +ARMNN_AUTO_TEST_CASE(Simple3dSoftmaxUint16, Simple3dSoftmaxUint16Test, 1.0f) +ARMNN_AUTO_TEST_CASE(Simple4dSoftmaxUint16, Simple4dSoftmaxUint16Test, 1.0f) + // Sigmoid Activation ARMNN_AUTO_TEST_CASE(SimpleSigmoid, SimpleSigmoidTest) ARMNN_AUTO_TEST_CASE(SimpleSigmoidUint8, SimpleSigmoidUint8Test) -- 2.7.4