aboutsummaryrefslogtreecommitdiff
path: root/src/backends/tosaCommon/test/OneToOneMappingTests.cpp
diff options
context:
space:
mode:
authorDavid Monahan <david.monahan@arm.com>2023-01-12 14:53:34 +0000
committerDavid Monahan <david.monahan@arm.com>2023-01-13 11:28:52 +0000
commitd7fca093be53b314e100e15a8fa080cb506b60a3 (patch)
treefaf4adbdd3154ffa6101bcbbf8c4839179ad180b /src/backends/tosaCommon/test/OneToOneMappingTests.cpp
parentc17a35f4b016c223add511a148ed3bb741770593 (diff)
downloadarmnn-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/tosaCommon/test/OneToOneMappingTests.cpp')
-rw-r--r--src/backends/tosaCommon/test/OneToOneMappingTests.cpp52
1 files changed, 51 insertions, 1 deletions
diff --git a/src/backends/tosaCommon/test/OneToOneMappingTests.cpp b/src/backends/tosaCommon/test/OneToOneMappingTests.cpp
index 4cc37918e5..6e532abcf7 100644
--- a/src/backends/tosaCommon/test/OneToOneMappingTests.cpp
+++ b/src/backends/tosaCommon/test/OneToOneMappingTests.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
//
@@ -252,6 +252,56 @@ TEST_CASE("GetTosaMappingFromLayer_Conv2dLayer")
AssertTosaOneToOneMappingBasicBlock(
basicBlock, inputShape, outputShape, Op_CONV2D, Attribute_ConvAttribute, descriptor, LayerType::Convolution2d);
}
+TEST_CASE("GetTosaMapping_ElementwiseUnaryLayerRsqrt")
+{
+ TensorInfo inputInfo = TensorInfo({ 2, 2 }, DataType::Float32, 0.0f, 0, true);
+ TensorInfo outputInfo = TensorInfo({ 2, 2 }, DataType::Float32, 0.0f, 0, true);
+ std::vector<std::vector<int32_t>> inputShape = {{ 2, 2 }};
+ std::vector<std::vector<int32_t>> outputShape = {{ 2, 2 }};
+
+ ElementwiseUnaryDescriptor unaryDescriptor = ElementwiseUnaryDescriptor(UnaryOperation::Rsqrt);
+ TosaSerializationBasicBlock* basicBlock =
+ GetTosaMapping(nullptr, LayerType::ElementwiseUnary, {&inputInfo,}, {&outputInfo}, unaryDescriptor);
+
+ AssertTosaOneToOneMappingBasicBlock(basicBlock,
+ inputShape,
+ outputShape,
+ tosa::Op_RSQRT,
+ tosa::Attribute_NONE,
+ unaryDescriptor,
+ LayerType::ElementwiseUnary);
+}
+TEST_CASE("GetTosaMappingFromLayer_ElementwiseUnaryLayerRsqrt")
+{
+ IRuntime::CreationOptions options;
+ IRuntimePtr runtime(IRuntime::Create(options));
+
+ // Builds up the structure of the network.
+ INetworkPtr net(INetwork::Create());
+ ElementwiseUnaryDescriptor unaryDescriptor = ElementwiseUnaryDescriptor(UnaryOperation::Rsqrt);
+ IConnectableLayer* input = net->AddInputLayer(0, "input0");
+ IConnectableLayer* unaryRsqrt = net->AddElementwiseUnaryLayer(unaryDescriptor, "rsqrt");
+ IConnectableLayer* output = net->AddOutputLayer(0, "output");
+
+ input->GetOutputSlot(0).Connect(unaryRsqrt->GetInputSlot(0));
+ unaryRsqrt->GetOutputSlot(0).Connect(output->GetInputSlot(0));
+ TensorInfo inputInfo = TensorInfo({ 2, 2 }, DataType::Float32, 0.0f, 0, true);
+ TensorInfo outputInfo = TensorInfo({ 2, 2 }, DataType::Float32, 0.0f, 0, true);
+ input->GetOutputSlot(0).SetTensorInfo(inputInfo);
+ unaryRsqrt->GetOutputSlot(0).SetTensorInfo(outputInfo);
+ std::vector<std::vector<int32_t>> inputShape = {{ 2, 2 }};
+ std::vector<std::vector<int32_t>> outputShape = {{ 2, 2 }};
+
+ TosaSerializationBasicBlock* basicBlock =
+ GetTosaMappingFromLayer(PolymorphicDowncast<Layer*>(unaryRsqrt));
+ AssertTosaOneToOneMappingBasicBlock(basicBlock,
+ inputShape,
+ outputShape,
+ tosa::Op_RSQRT,
+ tosa::Attribute_NONE,
+ unaryDescriptor,
+ LayerType::ElementwiseUnary);
+}
TEST_CASE("GetTosaMapping_MultiplicationLayer")
{