aboutsummaryrefslogtreecommitdiff
path: root/src/backends/tosaReference/test
diff options
context:
space:
mode:
authorMatthew Sloyan <matthew.sloyan@arm.com>2022-11-25 16:10:00 +0000
committerMatthew Sloyan <matthew.sloyan@arm.com>2022-12-08 12:57:47 +0000
commitc5fe6e71cd39096af7c2523ec2afe96008c51b0c (patch)
tree1486349bc36e17c1577465aab81d9eb3ca64e861 /src/backends/tosaReference/test
parent3106c7f1714aea556d06d9f1e8c7faaeaeca996d (diff)
downloadarmnn-c5fe6e71cd39096af7c2523ec2afe96008c51b0c.tar.gz
IVGCVSW-7168 Add Conv2d and Constant support to TOSA Reference Backend
* Added TOSA Conv2d and Constant mappings. * Added unique naming to mappings based on previous and following layers, so they are connected correctly. * Updated existing mappings with new naming convention. * Added all mappings to one main block in OptimizeSubgraphView. * Removed isMain from mapping functions. * Added Conv2d EndToEnd test. Signed-off-by: Matthew Sloyan <matthew.sloyan@arm.com> Change-Id: I27c3e238407c32379ce25a1f01dad11523ef5d2b
Diffstat (limited to 'src/backends/tosaReference/test')
-rw-r--r--src/backends/tosaReference/test/TosaRefEndToEndTests.cpp12
-rw-r--r--src/backends/tosaReference/test/TosaRefLayerSupportTests.cpp101
2 files changed, 106 insertions, 7 deletions
diff --git a/src/backends/tosaReference/test/TosaRefEndToEndTests.cpp b/src/backends/tosaReference/test/TosaRefEndToEndTests.cpp
index fbe1265fe3..4245f0d4c4 100644
--- a/src/backends/tosaReference/test/TosaRefEndToEndTests.cpp
+++ b/src/backends/tosaReference/test/TosaRefEndToEndTests.cpp
@@ -6,6 +6,7 @@
#include "backendsCommon/test/EndToEndTestImpl.hpp"
#include "backendsCommon/test/AdditionEndToEndTestImpl.hpp"
+#include "backendsCommon/test/Convolution2dEndToEndTestImpl.hpp"
#include "backendsCommon/test/Pooling2dEndToEndTestImpl.hpp"
#include <doctest/doctest.h>
@@ -30,6 +31,17 @@ TEST_CASE("TosaRefAdditionEndtoEndTestFloat16")
AdditionEndToEndFloat16<DataType::Float16>(tosaDefaultBackends);
}
+// Conv2d
+TEST_CASE("TosaRefConv2dEndtoEndTestFloat32")
+{
+ Convolution2dEndToEnd<armnn::DataType::Float32>(tosaDefaultBackends, armnn::DataLayout::NHWC);
+}
+
+TEST_CASE("TosaRefConv2dWithoutBiasEndtoEndTestFloat32")
+{
+ Convolution2dEndToEnd<armnn::DataType::Float32>(tosaDefaultBackends, armnn::DataLayout::NHWC, false);
+}
+
// Max Pool 2D
TEST_CASE("TosaRefMaxPool2DEndtoEndTestFloat32")
{
diff --git a/src/backends/tosaReference/test/TosaRefLayerSupportTests.cpp b/src/backends/tosaReference/test/TosaRefLayerSupportTests.cpp
index 48eca344bc..e6fbbf9688 100644
--- a/src/backends/tosaReference/test/TosaRefLayerSupportTests.cpp
+++ b/src/backends/tosaReference/test/TosaRefLayerSupportTests.cpp
@@ -58,11 +58,98 @@ TEST_CASE("IsLayerSupportedTosaReferenceAdditionUnsupported")
CHECK(!supported);
REQUIRE(reasonIfNotSupported.find(
- "TOSA Reference Operator: Op_ADD for input: Op_ADD_input0_") != std::string::npos);
+ "TOSA Reference Operator: Op_ADD for input: input0_") != std::string::npos);
REQUIRE(reasonIfNotSupported.find(
- "TOSA Reference Operator: Op_ADD for input: Op_ADD_input1_") != std::string::npos);
+ "TOSA Reference Operator: Op_ADD for input: input1_") != std::string::npos);
REQUIRE(reasonIfNotSupported.find(
- "TOSA Reference Operator: Op_ADD for output: Op_ADD_output0_") != std::string::npos);
+ "TOSA Reference Operator: Op_ADD for output: output0_") != std::string::npos);
+}
+
+TEST_CASE("IsLayerSupportedTosaReferenceConstant")
+{
+ armnn::TensorInfo outputInfo({1,1,3,4}, armnn::DataType::Float32);
+
+ armnn::TosaRefLayerSupport supportChecker;
+ std::string reasonIfNotSupported;
+ auto supported = supportChecker.IsLayerSupported(armnn::LayerType::Constant,
+ {outputInfo},
+ armnn::BaseDescriptor(),
+ armnn::EmptyOptional(),
+ armnn::EmptyOptional(),
+ reasonIfNotSupported);
+
+ CHECK(supported);
+}
+
+TEST_CASE("IsLayerSupportedTosaReferenceConstantUnsupported")
+{
+ armnn::TensorInfo outputInfo({1,1,3,4}, armnn::DataType::Signed64);
+
+ armnn::TosaRefLayerSupport supportChecker;
+ std::string reasonIfNotSupported;
+ auto supported = supportChecker.IsLayerSupported(armnn::LayerType::Constant,
+ {outputInfo},
+ armnn::BaseDescriptor(),
+ armnn::EmptyOptional(),
+ armnn::EmptyOptional(),
+ reasonIfNotSupported);
+
+ CHECK(!supported);
+ REQUIRE(reasonIfNotSupported.find(
+ "TOSA Reference Operator: Op_CONST for output: constant_") != std::string::npos);
+}
+
+TEST_CASE("IsLayerSupportedTosaReferenceConv2d")
+{
+ armnn::TensorInfo inputInfo ({ 1, 5, 5, 1 }, armnn::DataType::Float32);
+ armnn::TensorInfo outputInfo({ 1, 3, 3, 1 }, armnn::DataType::Float32);
+ armnn::TensorInfo weightsInfo({ 1, 3, 3, 1 }, armnn::DataType::Float32);
+ armnn::TensorInfo biasesInfo ({ 1 }, armnn::DataType::Float32);
+
+ armnn::Convolution2dDescriptor desc;
+ desc.m_BiasEnabled = true;
+
+ armnn::TosaRefLayerSupport supportChecker;
+ std::string reasonIfNotSupported;
+ auto supported = supportChecker.IsLayerSupported(armnn::LayerType::Convolution2d,
+ {inputInfo, outputInfo, weightsInfo, biasesInfo},
+ desc,
+ armnn::EmptyOptional(),
+ armnn::EmptyOptional(),
+ reasonIfNotSupported);
+
+ CHECK(supported);
+}
+
+TEST_CASE("IsLayerSupportedTosaReferenceConv2dUnsupported")
+{
+ // If inputs and weights are Fp32, output must match.
+ armnn::TensorInfo inputInfo ({ 1, 5, 5, 1 }, armnn::DataType::Float32);
+ armnn::TensorInfo outputInfo({ 1, 3, 3, 1 }, armnn::DataType::Signed64);
+ armnn::TensorInfo weightsInfo({ 1, 3, 3, 1 }, armnn::DataType::Float32, 0.0f, 0, true);
+ armnn::TensorInfo biasesInfo ({ 1 }, armnn::DataType::Float32, 0.0f, 0, true);
+
+ armnn::Convolution2dDescriptor desc;
+ desc.m_BiasEnabled = true;
+
+ armnn::TosaRefLayerSupport supportChecker;
+ std::string reasonIfNotSupported;
+ auto supported = supportChecker.IsLayerSupported(armnn::LayerType::Convolution2d,
+ {inputInfo, outputInfo, weightsInfo, biasesInfo},
+ desc,
+ armnn::EmptyOptional(),
+ armnn::EmptyOptional(),
+ reasonIfNotSupported);
+
+ CHECK(!supported);
+ REQUIRE(reasonIfNotSupported.find(
+ "TOSA Reference Operator: Op_CONV2D for input 0: input0_") != std::string::npos);
+ REQUIRE(reasonIfNotSupported.find(
+ "input 1: input1_") != std::string::npos);
+ REQUIRE(reasonIfNotSupported.find(
+ "and output: output0_") != std::string::npos);
+ REQUIRE(reasonIfNotSupported.find(
+ "has an unsupported input data type combination.") != std::string::npos);
}
TEST_CASE("IsLayerSupportedTosaReferenceMaxPooling2d")
@@ -150,9 +237,9 @@ TEST_CASE("IsLayerSupportedTosaReferenceMaxPooling2dUnsupported")
CHECK(!supported);
REQUIRE(reasonIfNotSupported.find(
- "TOSA Reference Operator: Op_MAX_POOL2D for input: Op_MAX_POOL2D_input0_") != std::string::npos);
+ "TOSA Reference Operator: Op_MAX_POOL2D for input: input0_") != std::string::npos);
REQUIRE(reasonIfNotSupported.find(
- "TOSA Reference Operator: Op_MAX_POOL2D for output: Op_MAX_POOL2D_output0_") != std::string::npos);
+ "TOSA Reference Operator: Op_MAX_POOL2D for output: output0_") != std::string::npos);
}
TEST_CASE("IsLayerSupportedTosaReferenceAvgPooling2dUnsupported_InputOutputDatatypeDifferent")
@@ -177,9 +264,9 @@ TEST_CASE("IsLayerSupportedTosaReferenceAvgPooling2dUnsupported_InputOutputDatat
CHECK(!supported);
REQUIRE(reasonIfNotSupported.find(
- "TOSA Reference Operator: Op_AVG_POOL2D for input: Op_PAD_intermediate0_") != std::string::npos);
+ "TOSA Reference Operator: Op_AVG_POOL2D for input: intermediate0_") != std::string::npos);
REQUIRE(reasonIfNotSupported.find(
- " and output: Op_AVG_POOL2D_output0_") != std::string::npos);
+ " and output: output0_") != std::string::npos);
REQUIRE(reasonIfNotSupported.find(
" has an unsupported input data type: 8 to output data type: 10") != std::string::npos);
}