// // Copyright © 2020 Arm Ltd and Contributors. All rights reserved. // SPDX-License-Identifier: MIT // #pragma once #include #include namespace armnnDelegate { /// Can be used to assign input data from a vector to a model input. /// Example usage can be found in ResizeTesthelper.hpp template void FillInput(std::unique_ptr& interpreter, int inputIndex, std::vector& inputValues) { auto tfLiteDelegateInputId = interpreter->inputs()[inputIndex]; auto tfLiteDelageInputData = interpreter->typed_tensor(tfLiteDelegateInputId); for (unsigned int i = 0; i < inputValues.size(); ++i) { tfLiteDelageInputData[i] = inputValues[i]; } } // Can be used to compare the output tensor shape and values // from armnnDelegateInterpreter and tfLiteInterpreter. // Example usage can be found in ControlTestHelper.hpp template void CompareOutputData(std::unique_ptr& tfLiteInterpreter, std::unique_ptr& armnnDelegateInterpreter, std::vector& expectedOutputShape, std::vector& expectedOutputValues) { auto tfLiteDelegateOutputId = tfLiteInterpreter->outputs()[0]; auto tfLiteDelegateOutputTensor = tfLiteInterpreter->tensor(tfLiteDelegateOutputId); auto tfLiteDelageOutputData = tfLiteInterpreter->typed_tensor(tfLiteDelegateOutputId); auto armnnDelegateOutputId = armnnDelegateInterpreter->outputs()[0]; auto armnnDelegateOutputTensor = armnnDelegateInterpreter->tensor(armnnDelegateOutputId); auto armnnDelegateOutputData = armnnDelegateInterpreter->typed_tensor(armnnDelegateOutputId); for (size_t i = 0; i < expectedOutputShape.size(); i++) { CHECK(expectedOutputShape[i] == armnnDelegateOutputTensor->dims->data[i]); CHECK(tfLiteDelegateOutputTensor->dims->data[i] == expectedOutputShape[i]); CHECK(tfLiteDelegateOutputTensor->dims->data[i] == armnnDelegateOutputTensor->dims->data[i]); } for (size_t i = 0; i < expectedOutputValues.size(); i++) { CHECK(expectedOutputValues[i] == armnnDelegateOutputData[i]); CHECK(tfLiteDelageOutputData[i] == expectedOutputValues[i]); CHECK(tfLiteDelageOutputData[i] == armnnDelegateOutputData[i]); } } } // namespace armnnDelegate