aboutsummaryrefslogtreecommitdiff
path: root/delegate/test/ActivationTest.cpp
diff options
context:
space:
mode:
authorTianle Cheng <tianle.cheng@arm.com>2023-07-28 11:53:04 +0100
committerTianle Cheng <tianle.cheng@arm.com>2023-08-01 14:45:49 +0000
commitae93173f7b37285ed107d4fa38adbe8669280e25 (patch)
tree163da33eeda3896afefcbfa6d000e76ff939eb38 /delegate/test/ActivationTest.cpp
parent09e4d05b85cc5ed419d282cdfc0b153f83c3fa39 (diff)
downloadarmnn-ae93173f7b37285ed107d4fa38adbe8669280e25.tar.gz
IVGCVSW-7451 LEAKY_RELU not supported by delegate
* Added LEAKY_RELU support to classic and opaque delegate * CMake files updated * Test added Signed-off-by: Tianle Cheng <tianle.cheng@arm.com> Change-Id: Ib9a2ce8f637b14afcd796bbae11fd3fa03653a2c
Diffstat (limited to 'delegate/test/ActivationTest.cpp')
-rw-r--r--delegate/test/ActivationTest.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/delegate/test/ActivationTest.cpp b/delegate/test/ActivationTest.cpp
index 8f2f198f88..620c299803 100644
--- a/delegate/test/ActivationTest.cpp
+++ b/delegate/test/ActivationTest.cpp
@@ -170,6 +170,32 @@ void ActivationHardSwishTest(std::vector<armnn::BackendId>& backends)
outputExpectedData);
}
+void ActivationLeakyReLuTest(std::vector<armnn::BackendId>& backends)
+{
+ std::vector<float> inputData = {
+ -0.1f, -0.2f, -0.3f, -0.4f,
+ 0.1f, 0.2f, 0.3f, 0.4f,
+ -1.0f, -2.0f, -3.0f, -4.0f,
+ 1.0f, 2.0f, 3.0f, 4.0f
+ };
+
+ float alpha = 0.3f;
+
+ // Calculate output values for input.
+ auto f = [alpha](float value)
+ {
+ return value > 0 ? value : value * alpha;
+ };
+ std::vector<float> outputExpectedData(inputData.size());
+ std::transform(inputData.begin(), inputData.end(), outputExpectedData.begin(), f);
+
+ ActivationTest(tflite::BuiltinOperator_LEAKY_RELU,
+ backends,
+ inputData,
+ outputExpectedData,
+ alpha);
+}
+
TEST_SUITE("Activation_CpuRefTests")
{
@@ -209,6 +235,12 @@ TEST_CASE ("Activation_HardSwish_CpuRef_Test")
ActivationHardSwishTest(backends);
}
+TEST_CASE ("Activation_LeakyRelu_CpuRef_Test")
+{
+ std::vector<armnn::BackendId> backends = { armnn::Compute::CpuRef };
+ ActivationLeakyReLuTest(backends);
+}
+
}
TEST_SUITE("Activation_CpuAccTests")
@@ -250,6 +282,12 @@ TEST_CASE ("Activation_HardSwish_CpuAcc_Test")
ActivationHardSwishTest(backends);
}
+TEST_CASE ("Activation_LeakyRelu_CpuAcc_Test")
+{
+ std::vector<armnn::BackendId> backends = { armnn::Compute::CpuAcc };
+ ActivationLeakyReLuTest(backends);
+}
+
}
TEST_SUITE("Activation_GpuAccTests")
@@ -291,6 +329,12 @@ TEST_CASE ("Activation_HardSwish_GpuAcc_Test")
ActivationHardSwishTest(backends);
}
+TEST_CASE ("Activation_LeakyRelu_GpuAcc_Test")
+{
+ std::vector<armnn::BackendId> backends = { armnn::Compute::GpuAcc };
+ ActivationLeakyReLuTest(backends);
+}
+
}
} // namespace armnnDelegate \ No newline at end of file