aboutsummaryrefslogtreecommitdiff
path: root/delegate/test
diff options
context:
space:
mode:
authorMatthew Sloyan <matthew.sloyan@arm.com>2023-04-04 12:06:14 +0100
committerMatthew Sloyan <matthew.sloyan@arm.com>2023-04-07 18:23:12 +0100
commit65c21a1eeff32f3abf91c3a638252ceb1ae5c51e (patch)
tree9dfdf5727687c09a932f8d8dd2f2047e3b5690cd /delegate/test
parent40847fc1f8ae7b7f56ca16eec92d1b46929f53e3 (diff)
downloadarmnn-65c21a1eeff32f3abf91c3a638252ceb1ae5c51e.tar.gz
IVGCVSW-7563 Implement DelegateTestInterpreter for opaque delegate
* Added opaque delegate DelegateTestInterpreter implementation * Moved classic specific tests to ArmnnClassicDelegateTest.cpp * Moved opaque specific tests to ArmnnOpaqueDelegateTest.cpp * Removed ArmnnDelegateTest.cpp * Moved TfLiteStableDelegate implementation to armnn_delegate.cpp Signed-off-by: Matthew Sloyan <matthew.sloyan@arm.com> Change-Id: Ifc92b6fb38dc370f3fb88a4daca56d457e74bc2e
Diffstat (limited to 'delegate/test')
-rw-r--r--delegate/test/ArmnnDelegateTest.cpp107
1 files changed, 0 insertions, 107 deletions
diff --git a/delegate/test/ArmnnDelegateTest.cpp b/delegate/test/ArmnnDelegateTest.cpp
deleted file mode 100644
index bd5ed6059c..0000000000
--- a/delegate/test/ArmnnDelegateTest.cpp
+++ /dev/null
@@ -1,107 +0,0 @@
-//
-// Copyright © 2020, 2023 Arm Ltd and Contributors. All rights reserved.
-// SPDX-License-Identifier: MIT
-//
-
-#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
-#include <doctest/doctest.h>
-
-#include <classic/include/armnn_delegate.hpp>
-
-#include <tensorflow/lite/kernels/builtin_op_kernels.h>
-#include <tensorflow/lite/interpreter.h>
-#include <tensorflow/lite/kernels/register.h>
-
-namespace armnnDelegate
-{
-
-TEST_SUITE("ArmnnDelegate")
-{
-
-TEST_CASE ("ArmnnDelegate Registered")
-{
- using namespace tflite;
- auto tfLiteInterpreter = std::make_unique<Interpreter>();
-
- tfLiteInterpreter->AddTensors(3);
- tfLiteInterpreter->SetInputs({0, 1});
- tfLiteInterpreter->SetOutputs({2});
-
- tfLiteInterpreter->SetTensorParametersReadWrite(0, kTfLiteFloat32, "input1", {1,2,2,1}, TfLiteQuantization());
- tfLiteInterpreter->SetTensorParametersReadWrite(1, kTfLiteFloat32, "input2", {1,2,2,1}, TfLiteQuantization());
- tfLiteInterpreter->SetTensorParametersReadWrite(2, kTfLiteFloat32, "output", {1,2,2,1}, TfLiteQuantization());
-
- tflite::ops::builtin::BuiltinOpResolver opResolver;
- const TfLiteRegistration* opRegister = opResolver.FindOp(BuiltinOperator_ADD, 1);
- tfLiteInterpreter->AddNodeWithParameters({0, 1}, {2}, "", 0, nullptr, opRegister);
-
- // Create the Armnn Delegate
- std::vector<armnn::BackendId> backends = { armnn::Compute::CpuRef };
- std::vector<armnn::BackendOptions> backendOptions;
- backendOptions.emplace_back(
- armnn::BackendOptions{ "BackendName",
- {
- { "Option1", 42 },
- { "Option2", true }
- }}
- );
-
- armnnDelegate::DelegateOptions delegateOptions(backends, backendOptions);
- std::unique_ptr<TfLiteDelegate, decltype(&armnnDelegate::TfLiteArmnnDelegateDelete)>
- theArmnnDelegate(armnnDelegate::TfLiteArmnnDelegateCreate(delegateOptions),
- armnnDelegate::TfLiteArmnnDelegateDelete);
-
- auto status = tfLiteInterpreter->ModifyGraphWithDelegate(std::move(theArmnnDelegate));
- CHECK(status == kTfLiteOk);
- CHECK(tfLiteInterpreter != nullptr);
-}
-
-TEST_CASE ("ArmnnDelegateOptimizerOptionsRegistered")
-{
- using namespace tflite;
- auto tfLiteInterpreter = std::make_unique<Interpreter>();
-
- tfLiteInterpreter->AddTensors(3);
- tfLiteInterpreter->SetInputs({0, 1});
- tfLiteInterpreter->SetOutputs({2});
-
- tfLiteInterpreter->SetTensorParametersReadWrite(0, kTfLiteFloat32, "input1", {1,2,2,1}, TfLiteQuantization());
- tfLiteInterpreter->SetTensorParametersReadWrite(1, kTfLiteFloat32, "input2", {1,2,2,1}, TfLiteQuantization());
- tfLiteInterpreter->SetTensorParametersReadWrite(2, kTfLiteFloat32, "output", {1,2,2,1}, TfLiteQuantization());
-
- tflite::ops::builtin::BuiltinOpResolver opResolver;
- const TfLiteRegistration* opRegister = opResolver.FindOp(BuiltinOperator_ADD, 1);
- tfLiteInterpreter->AddNodeWithParameters({0, 1}, {2}, "", 0, nullptr, opRegister);
-
- // Create the Armnn Delegate
- std::vector<armnn::BackendId> backends = { armnn::Compute::CpuRef };
-
- armnn::OptimizerOptions optimizerOptions(true, true, false, true);
-
- armnnDelegate::DelegateOptions delegateOptions(backends, optimizerOptions);
- std::unique_ptr<TfLiteDelegate, decltype(&armnnDelegate::TfLiteArmnnDelegateDelete)>
- theArmnnDelegate(armnnDelegate::TfLiteArmnnDelegateCreate(delegateOptions),
- armnnDelegate::TfLiteArmnnDelegateDelete);
-
- auto status = tfLiteInterpreter->ModifyGraphWithDelegate(std::move(theArmnnDelegate));
- CHECK(status == kTfLiteOk);
- CHECK(tfLiteInterpreter != nullptr);
-}
-
-TEST_CASE ("DelegateOptions_ClassicDelegateDefault")
-{
- // Check default options can be created
- auto options = TfLiteArmnnDelegateOptionsDefault();
-
- // Check Classic delegate created
- auto classicDelegate = armnnDelegate::TfLiteArmnnDelegateCreate(options);
- CHECK(classicDelegate);
-
- // Check Classic Delegate can be deleted
- CHECK(classicDelegate->data_);
- armnnDelegate::TfLiteArmnnDelegateDelete(classicDelegate);
-}
-
-}
-
-} // namespace armnnDelegate