From 4cd29a046c3d46917d84d12feb668969af23a39e Mon Sep 17 00:00:00 2001 From: Keith Davis Date: Mon, 9 Sep 2019 14:49:20 +0100 Subject: IVGCVSW-3712 Add Transpose into TfLite Parser Signed-off-by: Keith Davis Change-Id: I94e975ede3876c812f0f26b040e8c50a5597f86a --- src/armnnTfLiteParser/test/Transpose.cpp | 125 +++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 src/armnnTfLiteParser/test/Transpose.cpp (limited to 'src/armnnTfLiteParser/test') diff --git a/src/armnnTfLiteParser/test/Transpose.cpp b/src/armnnTfLiteParser/test/Transpose.cpp new file mode 100644 index 0000000000..4430438bb9 --- /dev/null +++ b/src/armnnTfLiteParser/test/Transpose.cpp @@ -0,0 +1,125 @@ +// +// Copyright © 2019 Arm Ltd. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#include +#include "ParserFlatbuffersFixture.hpp" +#include "../TfLiteParser.hpp" + +BOOST_AUTO_TEST_SUITE(TensorflowLiteParser) + +struct TransposeFixture : public ParserFlatbuffersFixture +{ + explicit TransposeFixture(const std::string & inputShape, + const std::string & outputShape) + { + m_JsonString = R"( + { + "version": 3, + "operator_codes": [ + { + "builtin_code": "TRANSPOSE", + "version": 1 + } + ], + "subgraphs": [ + { + "tensors": [ + { + "shape": )" + inputShape + R"(, + "type": "FLOAT32", + "buffer": 3, + "name": "Placeholder", + "quantization": { + "min": [ + 0.0 + ], + "max": [ + 255.0 + ], + "details_type": 0, + "quantized_dimension": 0 + }, + "is_variable": false + }, + { + "shape": )" + outputShape + R"(, + "type": "FLOAT32", + "buffer": 2, + "name": "transpose", + "quantization": { + "details_type": 0, + "quantized_dimension": 0 + }, + "is_variable": false + }, + { + "shape": [ + 3 + ], + "type": "INT32", + "buffer": 1, + "name": "transpose/perm", + "quantization": { + "details_type": 0, + "quantized_dimension": 0 + }, + "is_variable": false + } + ], + "inputs": [ + 0 + ], + "outputs": [ + 1 + ], + "operators": [ + { + "opcode_index": 0, + "inputs": [ + 0, + 2 + ], + "outputs": [ + 1 + ], + "builtin_options_type": "TransposeOptions", + "builtin_options": { + }, + "custom_options_format": "FLEXBUFFERS" + } + ] + } + ], + "description": "TOCO Converted.", + "buffers": [ + { }, + { }, + { }, + { } + ] + } + )"; + Setup(); + } +}; + +struct SimpleTransposeFixture : TransposeFixture +{ + SimpleTransposeFixture() : TransposeFixture("[ 2, 2, 3 ]", + "[ 2, 3, 2 ]") {} +}; + +BOOST_FIXTURE_TEST_CASE(SimpleTranspose, SimpleTransposeFixture) +{ + RunTest<3, armnn::DataType::Float32>( + 0, + {{"Placeholder", { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }}}, + + {{"transpose", { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }}}); + BOOST_TEST((m_Parser->GetNetworkOutputBindingInfo(0, "transpose").second.GetShape() + == armnn::TensorShape({2,3,2}))); +} + +BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file -- cgit v1.2.1