From 7515d0730acc926316886a85401bcd36f640627e Mon Sep 17 00:00:00 2001 From: Matthew Sloyan Date: Wed, 16 Dec 2020 12:50:01 +0000 Subject: IVGCVSW-5614 Enable Hard Swish and Elu activations * Enabled Hard Swish and Elu in TfLiteDelegate * Added support for Elu in TfLiteParser Signed-off-by: Matthew Sloyan Change-Id: If09321b58568a98e14cabce610a1586556da041e --- delegate/src/test/ActivationTestHelper.hpp | 36 +++++++++++------------------- 1 file changed, 13 insertions(+), 23 deletions(-) (limited to 'delegate/src/test/ActivationTestHelper.hpp') diff --git a/delegate/src/test/ActivationTestHelper.hpp b/delegate/src/test/ActivationTestHelper.hpp index 2368a36931..0f4d944685 100644 --- a/delegate/src/test/ActivationTestHelper.hpp +++ b/delegate/src/test/ActivationTestHelper.hpp @@ -5,6 +5,8 @@ #pragma once +#include "TestUtils.hpp" + #include #include @@ -79,7 +81,7 @@ void ActivationTest(tflite::BuiltinOperator activationOperatorCode, std::vector& expectedOutputValues) { using namespace tflite; - const std::vector inputShape { { 4, 1, 4} }; + std::vector inputShape { { 4, 1, 4} }; std::vector modelBuffer = CreateActivationTfLiteModel(activationOperatorCode, ::tflite::TensorType_FLOAT32, inputShape); @@ -108,33 +110,21 @@ void ActivationTest(tflite::BuiltinOperator activationOperatorCode, CHECK(armnnDelegateInterpreter->ModifyGraphWithDelegate(theArmnnDelegate.get()) == kTfLiteOk); // Set input data - auto tfLiteDelegateInputId = tfLiteInterpreter->inputs()[0]; - auto tfLiteDelageInputData = tfLiteInterpreter->typed_tensor(tfLiteDelegateInputId); - for (unsigned int i = 0; i < inputValues.size(); ++i) - { - tfLiteDelageInputData[i] = inputValues[i]; - } - - auto armnnDelegateInputId = armnnDelegateInterpreter->inputs()[0]; - auto armnnDelegateInputData = armnnDelegateInterpreter->typed_tensor(armnnDelegateInputId); - for (unsigned int i = 0; i < inputValues.size(); ++i) - { - armnnDelegateInputData[i] = inputValues[i]; - } + armnnDelegate::FillInput(tfLiteInterpreter, 0, inputValues); + armnnDelegate::FillInput(armnnDelegateInterpreter, 0, inputValues); + // Run EnqueWorkload CHECK(tfLiteInterpreter->Invoke() == kTfLiteOk); CHECK(armnnDelegateInterpreter->Invoke() == kTfLiteOk); // Compare output data - auto tfLiteDelegateOutputId = tfLiteInterpreter->outputs()[0]; - auto tfLiteDelageOutputData = tfLiteInterpreter->typed_tensor(tfLiteDelegateOutputId); - auto armnnDelegateOutputId = armnnDelegateInterpreter->outputs()[0]; - auto armnnDelegateOutputData = armnnDelegateInterpreter->typed_tensor(armnnDelegateOutputId); - for (size_t i = 0; i < inputValues.size(); i++) - { - CHECK(expectedOutputValues[i] == doctest::Approx(armnnDelegateOutputData[i])); - CHECK(tfLiteDelageOutputData[i] == doctest::Approx(armnnDelegateOutputData[i])); - } + armnnDelegate::CompareOutputData(tfLiteInterpreter, + armnnDelegateInterpreter, + inputShape, + expectedOutputValues); + + tfLiteInterpreter.reset(nullptr); + armnnDelegateInterpreter.reset(nullptr); } } // anonymous namespace \ No newline at end of file -- cgit v1.2.1