diff options
author | Matthew Sloyan <matthew.sloyan@arm.com> | 2020-11-13 09:47:35 +0000 |
---|---|---|
committer | Francis Murtagh <francis.murtagh@arm.com> | 2020-11-17 12:50:19 +0000 |
commit | 91c4171421633b3ff9764bd586f43137aef0ff1a (patch) | |
tree | 5462dfa28832b6da848a3acb5ba471f0813ec52b /delegate/src/test/TestUtils.hpp | |
parent | 145c88f851d12d2cadc2f080d232c1d5963d6e47 (diff) | |
download | armnn-91c4171421633b3ff9764bd586f43137aef0ff1a.tar.gz |
IVGCVSW-5486 TfLiteDelegate: Implement Concat and Mean operators
* Implemented Concatenation & Mean operator.
* Added unit tests for Concatenation & Mean operator.
* Added CompareOutputData function to TestUtils.hpp.
Signed-off-by: Matthew Sloyan <matthew.sloyan@arm.com>
Change-Id: I31b7b1517a9ce041c3269f69f16a419f967d0fb0
Diffstat (limited to 'delegate/src/test/TestUtils.hpp')
-rw-r--r-- | delegate/src/test/TestUtils.hpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/delegate/src/test/TestUtils.hpp b/delegate/src/test/TestUtils.hpp index 162d62f3bb..9bbab8f62b 100644 --- a/delegate/src/test/TestUtils.hpp +++ b/delegate/src/test/TestUtils.hpp @@ -7,6 +7,8 @@ #include <tensorflow/lite/interpreter.h> +#include <doctest/doctest.h> + namespace armnnDelegate { @@ -23,4 +25,35 @@ void FillInput(std::unique_ptr<tflite::Interpreter>& interpreter, int inputIndex } } +// Can be used to compare the output tensor shape and values +// from armnnDelegateInterpreter and tfLiteInterpreter. +// Example usage can be found in ControlTestHelper.hpp +template <typename T> +void CompareOutputData(std::unique_ptr<tflite::Interpreter>& tfLiteInterpreter, + std::unique_ptr<tflite::Interpreter>& armnnDelegateInterpreter, + std::vector<int32_t>& expectedOutputShape, + std::vector<T>& expectedOutputValues) +{ + auto tfLiteDelegateOutputId = tfLiteInterpreter->outputs()[0]; + auto tfLiteDelegateOutputTensor = tfLiteInterpreter->tensor(tfLiteDelegateOutputId); + auto tfLiteDelageOutputData = tfLiteInterpreter->typed_tensor<T>(tfLiteDelegateOutputId); + auto armnnDelegateOutputId = armnnDelegateInterpreter->outputs()[0]; + auto armnnDelegateOutputTensor = armnnDelegateInterpreter->tensor(armnnDelegateOutputId); + auto armnnDelegateOutputData = armnnDelegateInterpreter->typed_tensor<T>(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 |