aboutsummaryrefslogtreecommitdiff
path: root/src/backends/reference
diff options
context:
space:
mode:
authorFrancis Murtagh <francis.murtagh@arm.com>2019-06-25 10:57:10 +0100
committerFrancis Murtagh <francis.murtagh@arm.com>2019-06-26 11:43:29 +0100
commitd0dfe178e3e6729cebd1a60d614f794e3c2ab72d (patch)
tree8586d52d7b5522d0f5ec5d39cb39b9ff9142d3d7 /src/backends/reference
parent96a709d87e0ae7d67dfa842c49a7cb9c3f9b5b86 (diff)
downloadarmnn-d0dfe178e3e6729cebd1a60d614f794e3c2ab72d.tar.gz
IVGCVSW-3249 Extend the BatchToSpace workload to support QSymm16
* Add reference supportedness validation checks. * Call unit tests with QSymm16 data type. Change-Id: Ie6621ca7072dfc69278198c53e09b090275a7fff Signed-off-by: Francis Murtagh <francis.murtagh@arm.com>
Diffstat (limited to 'src/backends/reference')
-rw-r--r--src/backends/reference/RefLayerSupport.cpp47
-rw-r--r--src/backends/reference/test/RefCreateWorkloadTests.cpp11
-rw-r--r--src/backends/reference/test/RefLayerTests.cpp17
3 files changed, 64 insertions, 11 deletions
diff --git a/src/backends/reference/RefLayerSupport.cpp b/src/backends/reference/RefLayerSupport.cpp
index 4e9a67879f..1f37420e42 100644
--- a/src/backends/reference/RefLayerSupport.cpp
+++ b/src/backends/reference/RefLayerSupport.cpp
@@ -359,14 +359,45 @@ bool RefLayerSupport::IsBatchToSpaceNdSupported(const TensorInfo& input,
Optional<std::string&> reasonIfUnsupported) const
{
ignore_unused(descriptor);
- return (IsSupportedForDataTypeRef(reasonIfUnsupported,
- input.GetDataType(),
- &TrueFunc<>,
- &TrueFunc<>) &&
- IsSupportedForDataTypeRef(reasonIfUnsupported,
- output.GetDataType(),
- &TrueFunc<>,
- &TrueFunc<>));
+
+ bool supported = true;
+
+ std::string batchToSpaceNdLayerStr = "batchToSpaceNd";
+ std::string inputTensorStr = "input";
+ std::string outputTensorStr = "output";
+
+ // Define supported types.
+ std::array<DataType,3> supportedTypes =
+ {
+ DataType::Float32,
+ DataType::QuantisedAsymm8,
+ DataType::QuantisedSymm16
+ };
+
+ supported &= CheckSupportRule(TypeAnyOf(input, supportedTypes), reasonIfUnsupported,
+ "Reference BatchToSpaceNd: input type not supported.");
+
+ supported &= CheckSupportRule(TypeAnyOf(output, supportedTypes), reasonIfUnsupported,
+ "Reference BatchToSpaceNd: output type not supported.");
+
+ supported &= CheckSupportRule(TypesAreEqual(input, output), reasonIfUnsupported,
+ "Reference BatchToSpaceNd: input and output types mismatched.");
+
+ supported &= CheckSupportRule(TensorNumDimensionsAreCorrect(output, 4),
+ reasonIfUnsupported,
+ CreateIncorrectDimensionsErrorMsg(4,
+ output.GetNumDimensions(),
+ batchToSpaceNdLayerStr,
+ outputTensorStr).data());
+
+ supported &= CheckSupportRule(TensorNumDimensionsAreCorrect(input, 4),
+ reasonIfUnsupported,
+ CreateIncorrectDimensionsErrorMsg(4,
+ input.GetNumDimensions(),
+ batchToSpaceNdLayerStr,
+ inputTensorStr).data());
+
+ return supported;
}
bool RefLayerSupport::IsConcatSupported(const std::vector<const TensorInfo*> inputs,
diff --git a/src/backends/reference/test/RefCreateWorkloadTests.cpp b/src/backends/reference/test/RefCreateWorkloadTests.cpp
index 67b1d945db..68df3495da 100644
--- a/src/backends/reference/test/RefCreateWorkloadTests.cpp
+++ b/src/backends/reference/test/RefCreateWorkloadTests.cpp
@@ -339,7 +339,7 @@ BOOST_AUTO_TEST_CASE(CreateFullyConnectedWorkloadQuantisedAsymm8)
RefCreateFullyConnectedWorkloadTest<RefFullyConnectedWorkload, armnn::DataType::QuantisedAsymm8>();
}
-BOOST_AUTO_TEST_CASE(CreateFullyConnectedWorkloadQuantisedAsymm16)
+BOOST_AUTO_TEST_CASE(CreateFullyConnectedWorkloadQuantisedSymm16)
{
RefCreateFullyConnectedWorkloadTest<RefFullyConnectedWorkload, armnn::DataType::QuantisedSymm16>();
}
@@ -700,8 +700,8 @@ static void RefCreateBatchToSpaceNdTest()
auto workload = CreateBatchToSpaceNdWorkloadTest<BatchToSpaceNdWorkloadType, DataType>(factory, graph);
CheckInputOutput(std::move(workload),
- TensorInfo({ 1, 1 }, DataType),
- TensorInfo({ 1, 1 }, DataType));
+ TensorInfo({ 1, 1, 1, 1 }, DataType),
+ TensorInfo({ 1, 1, 1, 1 }, DataType));
}
BOOST_AUTO_TEST_CASE(CreateBatchToSpaceNdFloat32)
@@ -714,6 +714,11 @@ BOOST_AUTO_TEST_CASE(CreateBatchToSpaceNdUint8)
RefCreateBatchToSpaceNdTest<RefBatchToSpaceNdWorkload, armnn::DataType::QuantisedAsymm8>();
}
+BOOST_AUTO_TEST_CASE(CreateBatchToSpaceNdQSymm16)
+{
+ RefCreateBatchToSpaceNdTest<RefBatchToSpaceNdWorkload, armnn::DataType::QuantisedSymm16>();
+}
+
template <typename L2NormalizationWorkloadType, armnn::DataType DataType>
static void RefCreateL2NormalizationTest(DataLayout dataLayout)
{
diff --git a/src/backends/reference/test/RefLayerTests.cpp b/src/backends/reference/test/RefLayerTests.cpp
index f933bfe3e1..b997a14e9d 100644
--- a/src/backends/reference/test/RefLayerTests.cpp
+++ b/src/backends/reference/test/RefLayerTests.cpp
@@ -828,6 +828,14 @@ ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNhwcUint5, BatchToSpaceNdNhwcTest5<armnn::Da
ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNhwcUint6, BatchToSpaceNdNhwcTest6<armnn::DataType::QuantisedAsymm8>)
ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNhwcUint7, BatchToSpaceNdNhwcTest7<armnn::DataType::QuantisedAsymm8>)
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNhwcQsymm16_1, BatchToSpaceNdNhwcTest1<armnn::DataType::QuantisedSymm16>)
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNhwcQsymm16_2, BatchToSpaceNdNhwcTest2<armnn::DataType::QuantisedSymm16>)
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNhwcQsymm16_3, BatchToSpaceNdNhwcTest3<armnn::DataType::QuantisedSymm16>)
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNhwcQsymm16_4, BatchToSpaceNdNhwcTest4<armnn::DataType::QuantisedSymm16>)
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNhwcQsymm16_5, BatchToSpaceNdNhwcTest5<armnn::DataType::QuantisedSymm16>)
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNhwcQsymm16_6, BatchToSpaceNdNhwcTest6<armnn::DataType::QuantisedSymm16>)
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNhwcQsymm16_7, BatchToSpaceNdNhwcTest7<armnn::DataType::QuantisedSymm16>)
+
ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNchwFloat1, BatchToSpaceNdNchwTest1<armnn::DataType::Float32>)
ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNchwFloat2, BatchToSpaceNdNchwTest2<armnn::DataType::Float32>)
ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNchwFloat3, BatchToSpaceNdNchwTest3<armnn::DataType::Float32>)
@@ -844,6 +852,15 @@ ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNchwUint5, BatchToSpaceNdNchwTest5<armnn::Da
ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNchwUint6, BatchToSpaceNdNchwTest6<armnn::DataType::QuantisedAsymm8>)
ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNchwUint7, BatchToSpaceNdNchwTest7<armnn::DataType::QuantisedAsymm8>)
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNchwQsymm16_1, BatchToSpaceNdNchwTest1<armnn::DataType::QuantisedSymm16>)
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNchwQsymm16_2, BatchToSpaceNdNchwTest2<armnn::DataType::QuantisedSymm16>)
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNchwQsymm16_3, BatchToSpaceNdNchwTest3<armnn::DataType::QuantisedSymm16>)
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNchwQsymm16_4, BatchToSpaceNdNchwTest4<armnn::DataType::QuantisedSymm16>)
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNchwQsymm16_5, BatchToSpaceNdNchwTest5<armnn::DataType::QuantisedSymm16>)
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNchwQsymm16_6, BatchToSpaceNdNchwTest6<armnn::DataType::QuantisedSymm16>)
+ARMNN_AUTO_TEST_CASE(BatchToSpaceNdNchwQsymm16_7, BatchToSpaceNdNchwTest7<armnn::DataType::QuantisedSymm16>)
+
+
// SpaceToDepth
ARMNN_AUTO_TEST_CASE(SpaceToDepthNCHWAsymmQ8, SpaceToDepthNCHWAsymmQ8Test)
ARMNN_AUTO_TEST_CASE(SpaceToDepthNHWCAsymmQ8, SpaceToDepthNHWCAsymmQ8Test)