diff options
author | David Monahan <david.monahan@arm.com> | 2023-01-12 14:53:34 +0000 |
---|---|---|
committer | David Monahan <david.monahan@arm.com> | 2023-01-13 11:28:52 +0000 |
commit | d7fca093be53b314e100e15a8fa080cb506b60a3 (patch) | |
tree | faf4adbdd3154ffa6101bcbbf8c4839179ad180b /src/backends/tosaReference | |
parent | c17a35f4b016c223add511a148ed3bb741770593 (diff) | |
download | armnn-d7fca093be53b314e100e15a8fa080cb506b60a3.tar.gz |
IVGCVSW-7173 Add Rsqrt to Tosa Ref Backend
* Added ElementwiseUnary support with a mapping for Rsqrt
* Added unittests
* Added Rsqrt EndtoEnd tests for all backends
* Changed TosaRefLayerSupport to default to false on unsupported layers
Signed-off-by: David Monahan <david.monahan@arm.com>
Change-Id: I3eaa9c684647ead61520a563815581aa68bee51b
Diffstat (limited to 'src/backends/tosaReference')
3 files changed, 53 insertions, 4 deletions
diff --git a/src/backends/tosaReference/TosaRefLayerSupport.cpp b/src/backends/tosaReference/TosaRefLayerSupport.cpp index 6113b5861a..238801cb98 100644 --- a/src/backends/tosaReference/TosaRefLayerSupport.cpp +++ b/src/backends/tosaReference/TosaRefLayerSupport.cpp @@ -1,5 +1,5 @@ // -// Copyright © 2022 Arm Ltd and Contributors. All rights reserved. +// Copyright © 2022-2023 Arm Ltd and Contributors. All rights reserved. // SPDX-License-Identifier: MIT // @@ -68,6 +68,7 @@ bool TosaRefLayerSupport::IsLayerSupported(const LayerType& type, } break; } + case LayerType::ElementwiseUnary: case LayerType::Pooling2d: case LayerType::Reshape: case LayerType::Slice: @@ -89,7 +90,8 @@ bool TosaRefLayerSupport::IsLayerSupported(const LayerType& type, break; } default: - break; + // Default to false for all unsupported layers. + return false; } auto mappings = GetTosaMapping(nullptr, type, inputInfos, outputInfos, descriptor); diff --git a/src/backends/tosaReference/test/TosaRefEndToEndTests.cpp b/src/backends/tosaReference/test/TosaRefEndToEndTests.cpp index e19462e986..26cadd22db 100644 --- a/src/backends/tosaReference/test/TosaRefEndToEndTests.cpp +++ b/src/backends/tosaReference/test/TosaRefEndToEndTests.cpp @@ -1,5 +1,5 @@ // -// Copyright © 2022 Arm Ltd and Contributors. All rights reserved. +// Copyright © 2022-2023 Arm Ltd and Contributors. All rights reserved. // SPDX-License-Identifier: MIT // @@ -11,6 +11,7 @@ #include "backendsCommon/test/MultiplicationEndToEndTestImpl.hpp" #include "backendsCommon/test/Pooling2dEndToEndTestImpl.hpp" #include "backendsCommon/test/ReshapeEndToEndTestImpl.hpp" +#include "backendsCommon/test/ElementwiseUnaryEndToEndTestImpl.hpp" #include "backendsCommon/test/SliceEndToEndTestImpl.hpp" #include "backendsCommon/test/SubtractionEndToEndTestImpl.hpp" #include "backendsCommon/test/TransposeConvolution2dEndToEndTestImpl.hpp" @@ -138,6 +139,12 @@ TEST_CASE("TosaRefReshapeEndtoEndTestFloat16") ReshapeEndToEndFloat16<DataType::Float16>(tosaDefaultBackends); } +TEST_CASE("TosaRefRsqrtEndtoEndTestFloat32") +{ + ElementwiseUnarySimpleEndToEnd<armnn::DataType::Float32>(tosaDefaultBackends, + UnaryOperation::Rsqrt); +} + // Slice TEST_CASE("TosaRefSliceEndtoEndTestFloat32") { diff --git a/src/backends/tosaReference/test/TosaRefLayerSupportTests.cpp b/src/backends/tosaReference/test/TosaRefLayerSupportTests.cpp index 66dfbe8dff..e32894f0b6 100644 --- a/src/backends/tosaReference/test/TosaRefLayerSupportTests.cpp +++ b/src/backends/tosaReference/test/TosaRefLayerSupportTests.cpp @@ -1,5 +1,5 @@ // -// Copyright © 2022 Arm Ltd and Contributors. All rights reserved. +// Copyright © 2022-2023 Arm Ltd and Contributors. All rights reserved. // SPDX-License-Identifier: MIT // @@ -374,6 +374,46 @@ TEST_CASE("IsLayerSupportedTosaReferenceReshapeUnsupported") CHECK(!supported); } +TEST_CASE("IsLayerSupportedTosaReferenceRsqrt") +{ + TensorShape shape0 = {2,2}; + TensorShape outShape = {2,2}; + TensorInfo in0(shape0, DataType::Float32); + TensorInfo out(outShape, DataType::Float32); + + ElementwiseUnaryDescriptor desc(UnaryOperation::Rsqrt); + TosaRefLayerSupport supportChecker; + std::string reasonIfNotSupported; + auto supported = supportChecker.IsLayerSupported(LayerType::ElementwiseUnary, + {in0, out}, + desc, + EmptyOptional(), + EmptyOptional(), + reasonIfNotSupported); + + CHECK(supported); +} + +TEST_CASE("IsLayerSupportedTosaReferenceRsqrtUnsupported") +{ + TensorShape shape0 = {1,1,3,4}; + TensorShape outShape = {1,3,1,4}; + TensorInfo in0(shape0, DataType::Signed64); + TensorInfo out(outShape, DataType::Signed64); + + ElementwiseUnaryDescriptor desc(UnaryOperation::Rsqrt); + TosaRefLayerSupport supportChecker; + std::string reasonIfNotSupported; + auto supported = supportChecker.IsLayerSupported(LayerType::ElementwiseUnary, + {in0, out}, + desc, + EmptyOptional(), + EmptyOptional(), + reasonIfNotSupported); + + CHECK(!supported); +} + TEST_CASE("IsLayerSupportedTosaReferenceSlice") { TensorShape inShape = {3,2,3}; |