IVGCVSW-7344 Add LeakyRelu Activation support to TOSA Reference Backend
* Adding a one to many FP32 tosa mapping for Leaky Relu
* Added a few utilities that are needed
* Added new tests
Signed-off-by: Tracy Narine <tracy.narine@arm.com>
Change-Id: If1d7c57a523961581777a244416a7346a9310803
diff --git a/src/backends/tosaReference/TosaRefLayerSupport.cpp b/src/backends/tosaReference/TosaRefLayerSupport.cpp
index a38c431..dac0667 100644
--- a/src/backends/tosaReference/TosaRefLayerSupport.cpp
+++ b/src/backends/tosaReference/TosaRefLayerSupport.cpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2022-2023 Arm Ltd and Contributors. All rights reserved.
+// Copyright © 2022-2024 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -34,6 +34,10 @@
switch (type)
{
+ case LayerType::Activation:
+ inputInfos.push_back(&infos[0]);
+ outputInfos.push_back(&infos[1]);
+ break;
case LayerType::Input:
case LayerType::Output:
return true;
diff --git a/src/backends/tosaReference/test/TosaRefEndToEndTests.cpp b/src/backends/tosaReference/test/TosaRefEndToEndTests.cpp
index 63fa69d..7a3edaf 100644
--- a/src/backends/tosaReference/test/TosaRefEndToEndTests.cpp
+++ b/src/backends/tosaReference/test/TosaRefEndToEndTests.cpp
@@ -25,7 +25,7 @@
TEST_SUITE("TosaRefEndToEnd")
{
-std::vector<BackendId> tosaDefaultBackends = { "TosaRef" };
+static std::vector<BackendId> tosaDefaultBackends = { "TosaRef" };
// Addition
TEST_CASE("TosaRefAdditionEndtoEndTestFloat32")
diff --git a/src/backends/tosaReference/test/TosaRefLayerSupportTests.cpp b/src/backends/tosaReference/test/TosaRefLayerSupportTests.cpp
index 6f038ab..2da2875 100644
--- a/src/backends/tosaReference/test/TosaRefLayerSupportTests.cpp
+++ b/src/backends/tosaReference/test/TosaRefLayerSupportTests.cpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2022-2023 Arm Ltd and Contributors. All rights reserved.
+// Copyright © 2022-2024 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -287,6 +287,46 @@
CHECK(supported);
}
+TEST_CASE("IsLayerSupportedTosaReferenceLeakyReLuActivation")
+{
+ TensorInfo inputInfo1({1,1,3,4}, DataType::Float32);
+ TensorInfo inputInfo2({1,1,3,4}, DataType::Float32);
+ TensorInfo outputInfo({1,1,3,4}, DataType::Float32);
+
+ TosaRefLayerSupport supportChecker;
+ std::string reasonIfNotSupported;
+ ActivationDescriptor descriptor;
+ descriptor.m_Function = ActivationFunction::LeakyReLu;
+ auto supported = supportChecker.IsLayerSupported(LayerType::Activation,
+ {inputInfo1, inputInfo2, outputInfo},
+ descriptor,
+ EmptyOptional(),
+ EmptyOptional(),
+ reasonIfNotSupported);
+
+ CHECK(supported);
+}
+
+TEST_CASE("IsLayerSupportedTosaReferenceActivationUnsupported")
+{
+ TensorInfo inputInfo1({1,1,3,4}, DataType::Float32);
+ TensorInfo inputInfo2({1,1,3,4}, DataType::Float32);
+ TensorInfo outputInfo({1,1,3,4}, DataType::Float32);
+
+ TosaRefLayerSupport supportChecker;
+ std::string reasonIfNotSupported;
+ ActivationDescriptor descriptor;
+ descriptor.m_Function = ActivationFunction::HardSwish;
+ auto supported = supportChecker.IsLayerSupported(LayerType::Activation,
+ {inputInfo1, inputInfo2, outputInfo},
+ descriptor,
+ EmptyOptional(),
+ EmptyOptional(),
+ reasonIfNotSupported);
+
+ CHECK(!supported);
+}
+
TEST_CASE("IsLayerSupportedTosaReferenceMaxPooling2dUnsupported")
{
TensorShape inShape = {1,1,3,4};