From 0534e0364473c0b1244f96462cbde1808e92ce81 Mon Sep 17 00:00:00 2001 From: Sadik Armagan Date: Tue, 27 Oct 2020 17:30:18 +0000 Subject: IVGCVSW-5378 'TfLiteDelegate: Implement the ElementWiseUnary operators ' * Moved ElementwiseUnary operators tests into single file * Implemented FP32 test for supported ElementwiseUnary operators Signed-off-by: Sadik Armagan Change-Id: I4b7eab190c3c8edb50927b8e1e94dd353597efcb --- delegate/src/test/AbsTest.cpp | 98 ------------------------------------------- 1 file changed, 98 deletions(-) delete mode 100644 delegate/src/test/AbsTest.cpp (limited to 'delegate/src/test/AbsTest.cpp') diff --git a/delegate/src/test/AbsTest.cpp b/delegate/src/test/AbsTest.cpp deleted file mode 100644 index f9c345e6d2..0000000000 --- a/delegate/src/test/AbsTest.cpp +++ /dev/null @@ -1,98 +0,0 @@ -// -// Copyright © 2020 Arm Ltd and Contributors. All rights reserved. -// SPDX-License-Identifier: MIT -// - -#include "ElementwiseUnaryTestHelper.hpp" - -#include - -#include -#include -#include -#include -#include -#include - -#include - -namespace armnnDelegate -{ - -TEST_SUITE("AbsTest") -{ - -TEST_CASE ("AbsTestFloat32") -{ - using namespace tflite; - - const std::vector inputShape { { 3, 1, 2} }; - std::vector modelBuffer = CreateElementwiseUnaryTfLiteModel(BuiltinOperator_ABS, - ::tflite::TensorType_FLOAT32, - inputShape); - const Model* tfLiteModel = GetModel(modelBuffer.data()); - - // Create TfLite Interpreters - std::unique_ptr armnnDelegateInterpreter; - CHECK(InterpreterBuilder(tfLiteModel, ::tflite::ops::builtin::BuiltinOpResolver()) - (&armnnDelegateInterpreter) == kTfLiteOk); - CHECK(armnnDelegateInterpreter != nullptr); - CHECK(armnnDelegateInterpreter->AllocateTensors() == kTfLiteOk); - - std::unique_ptr tfLiteInterpreter; - CHECK(InterpreterBuilder(tfLiteModel, ::tflite::ops::builtin::BuiltinOpResolver()) - (&tfLiteInterpreter) == kTfLiteOk); - CHECK(tfLiteInterpreter != nullptr); - CHECK(tfLiteInterpreter->AllocateTensors() == kTfLiteOk); - - // Create the ArmNN Delegate - auto delegateOptions = TfLiteArmnnDelegateOptionsDefault(); - auto armnnDelegate = TfLiteArmnnDelegateCreate(delegateOptions); - CHECK(armnnDelegate != nullptr); - // Modify armnnDelegateInterpreter to use armnnDelegate - CHECK(armnnDelegateInterpreter->ModifyGraphWithDelegate(armnnDelegate) == kTfLiteOk); - - // Set input data - std::vector inputValues - { - -0.1f, -0.2f, -0.3f, - 0.1f, 0.2f, 0.3f - }; - 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]; - } - - // 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(std::abs(inputValues[i]) == armnnDelegateOutputData[i]); - CHECK(tfLiteDelageOutputData[i] == armnnDelegateOutputData[i]); - } -} - -} - -} // namespace armnnDelegate - - - -- cgit v1.2.1