From 0bb096d9cd11bec1a890066064c8a28c4a4fd6ee Mon Sep 17 00:00:00 2001 From: Cathal Corbett Date: Thu, 22 Dec 2022 13:09:38 +0000 Subject: IVGCVSW-7343 Add Transpose support to TOSA Reference Backend Signed-off-by: Cathal Corbett Change-Id: I11505f672349e1f04143edfdc2df8775f685372d --- src/backends/tosaReference/TosaRefLayerSupport.cpp | 2 +- .../tosaReference/test/TosaRefEndToEndTests.cpp | 7 ++++ .../test/TosaRefLayerSupportTests.cpp | 42 ++++++++++++++++++++++ 3 files changed, 50 insertions(+), 1 deletion(-) (limited to 'src/backends/tosaReference') diff --git a/src/backends/tosaReference/TosaRefLayerSupport.cpp b/src/backends/tosaReference/TosaRefLayerSupport.cpp index b37ecc4ab7..6113b5861a 100644 --- a/src/backends/tosaReference/TosaRefLayerSupport.cpp +++ b/src/backends/tosaReference/TosaRefLayerSupport.cpp @@ -71,7 +71,7 @@ bool TosaRefLayerSupport::IsLayerSupported(const LayerType& type, case LayerType::Pooling2d: case LayerType::Reshape: case LayerType::Slice: - // Setup inputs and outputs + case LayerType::Transpose: inputInfos.push_back(&infos[0]); outputInfos.push_back(&infos[1]); break; diff --git a/src/backends/tosaReference/test/TosaRefEndToEndTests.cpp b/src/backends/tosaReference/test/TosaRefEndToEndTests.cpp index 67b87ae8b9..e19462e986 100644 --- a/src/backends/tosaReference/test/TosaRefEndToEndTests.cpp +++ b/src/backends/tosaReference/test/TosaRefEndToEndTests.cpp @@ -14,6 +14,7 @@ #include "backendsCommon/test/SliceEndToEndTestImpl.hpp" #include "backendsCommon/test/SubtractionEndToEndTestImpl.hpp" #include "backendsCommon/test/TransposeConvolution2dEndToEndTestImpl.hpp" +#include "backendsCommon/test/TransposeEndToEndTestImpl.hpp" #include @@ -195,4 +196,10 @@ TEST_CASE("TosaRefSimpleTransposeConvolution2dEndToEndFloatNhwcTest") tosaDefaultBackends, armnn::DataLayout::NHWC); } +// Transpose +TEST_CASE("TosaRefTransposeEndtoEndTestFloat32") +{ + TransposeEndToEnd(tosaDefaultBackends); +} + } \ No newline at end of file diff --git a/src/backends/tosaReference/test/TosaRefLayerSupportTests.cpp b/src/backends/tosaReference/test/TosaRefLayerSupportTests.cpp index 9119b13557..66dfbe8dff 100644 --- a/src/backends/tosaReference/test/TosaRefLayerSupportTests.cpp +++ b/src/backends/tosaReference/test/TosaRefLayerSupportTests.cpp @@ -509,4 +509,46 @@ TEST_CASE("IsLayerSupportedTosaReferenceTransposeConv2dUnsupported") CHECK(!supported); } +TEST_CASE("IsLayerSupportedTosaReferenceTranspose") +{ + TensorShape inShape = { 1, 1, 5, 3 }; + TensorShape outShape = { 1, 5, 1, 3 }; + TensorInfo in(inShape, DataType::Float32); + TensorInfo out(outShape, DataType::Float32); + + TransposeDescriptor transposeDescriptor = TransposeDescriptor({ 0, 2, 1 ,3 }); + + TosaRefLayerSupport supportChecker; + std::string reasonIfNotSupported; + auto supported = supportChecker.IsLayerSupported(LayerType::Transpose, + {in, out}, + transposeDescriptor, + EmptyOptional(), + EmptyOptional(), + reasonIfNotSupported); + + CHECK(supported); +} + +TEST_CASE("IsLayerSupportedTosaReferenceTransposeUnsupported") +{ + TensorShape inShape = { 1, 1, 5, 3 }; + TensorShape outShape = { 1, 5, 1, 3 }; + TensorInfo in(inShape, DataType::Signed64); + TensorInfo out(outShape, DataType::Signed64); + + TransposeDescriptor transposeDescriptor = TransposeDescriptor({ 0, 2, 1 ,3 }); + + TosaRefLayerSupport supportChecker; + std::string reasonIfNotSupported; + auto supported = supportChecker.IsLayerSupported(LayerType::Transpose, + {in, out}, + transposeDescriptor, + EmptyOptional(), + EmptyOptional(), + reasonIfNotSupported); + + CHECK(!supported); +} + } -- cgit v1.2.1