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
diff --git a/src/backends/tosaReference/TosaRefLayerSupport.cpp b/src/backends/tosaReference/TosaRefLayerSupport.cpp
index 6113b58..238801c 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 @@
             }
             break;
         }
+        case LayerType::ElementwiseUnary:
         case LayerType::Pooling2d:
         case LayerType::Reshape:
         case LayerType::Slice:
@@ -89,7 +90,8 @@
             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 e19462e..26cadd2 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 @@
     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 66dfbe8..e32894f 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 @@
     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};