aboutsummaryrefslogtreecommitdiff
path: root/delegate/test/ActivationTestHelper.hpp
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/ActivationTestHelper.hpp
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/ActivationTestHelper.hpp')
-rw-r--r--delegate/test/ActivationTestHelper.hpp24
1 files changed, 20 insertions, 4 deletions
diff --git a/delegate/test/ActivationTestHelper.hpp b/delegate/test/ActivationTestHelper.hpp
index e1901b7d9f..b0a4d6785d 100644
--- a/delegate/test/ActivationTestHelper.hpp
+++ b/delegate/test/ActivationTestHelper.hpp
@@ -23,7 +23,8 @@ namespace
std::vector<char> CreateActivationTfLiteModel(tflite::BuiltinOperator activationOperatorCode,
tflite::TensorType tensorType,
- const std::vector <int32_t>& tensorShape)
+ const std::vector <int32_t>& tensorShape,
+ float alpha = 0)
{
using namespace tflite;
flatbuffers::FlatBufferBuilder flatBufferBuilder;
@@ -42,11 +43,24 @@ std::vector<char> CreateActivationTfLiteModel(tflite::BuiltinOperator activation
// create operator
const std::vector<int> operatorInputs{0};
const std::vector<int> operatorOutputs{1};
+
+ // builtin options
+ tflite::BuiltinOptions operatorBuiltinOptionsType = tflite::BuiltinOptions_NONE;
+ flatbuffers::Offset<void> operatorBuiltinOption = 0;
+
+ if (activationOperatorCode == tflite::BuiltinOperator_LEAKY_RELU)
+ {
+ operatorBuiltinOptionsType = tflite::BuiltinOptions_LeakyReluOptions;
+ operatorBuiltinOption = CreateLeakyReluOptions(flatBufferBuilder, alpha).Union();
+ }
+
flatbuffers::Offset <Operator> unaryOperator =
CreateOperator(flatBufferBuilder,
0,
flatBufferBuilder.CreateVector<int32_t>(operatorInputs.data(), operatorInputs.size()),
- flatBufferBuilder.CreateVector<int32_t>(operatorOutputs.data(), operatorOutputs.size()));
+ flatBufferBuilder.CreateVector<int32_t>(operatorOutputs.data(), operatorOutputs.size()),
+ operatorBuiltinOptionsType,
+ operatorBuiltinOption);
const std::vector<int> subgraphInputs{0};
const std::vector<int> subgraphOutputs{1};
@@ -78,13 +92,15 @@ std::vector<char> CreateActivationTfLiteModel(tflite::BuiltinOperator activation
void ActivationTest(tflite::BuiltinOperator activationOperatorCode,
std::vector<armnn::BackendId>& backends,
std::vector<float>& inputValues,
- std::vector<float>& expectedOutputValues)
+ std::vector<float>& expectedOutputValues,
+ float alpha = 0)
{
using namespace delegateTestInterpreter;
std::vector<int32_t> inputShape { { 4, 1, 4} };
std::vector<char> modelBuffer = CreateActivationTfLiteModel(activationOperatorCode,
::tflite::TensorType_FLOAT32,
- inputShape);
+ inputShape,
+ alpha);
// Setup interpreter with just TFLite Runtime.
auto tfLiteInterpreter = DelegateTestInterpreter(modelBuffer);