diff options
author | Sadik Armagan <sadik.armagan@arm.com> | 2018-10-01 11:51:37 +0100 |
---|---|---|
committer | Matthew Bentham <matthew.bentham@arm.com> | 2018-10-10 16:16:57 +0100 |
commit | 479045bdcac4faddbf567aa0f73d2899881f341c (patch) | |
tree | 5cd11ee39543ceda2730d21c1e7036543712a335 /src/armnnTfLiteParser/test | |
parent | e4ba53a85c559d4fe574305276ac815cf7995762 (diff) | |
download | armnn-479045bdcac4faddbf567aa0f73d2899881f341c.tar.gz |
IVGCVSW-1787 Add Support for Concatenation on TfLite parser
* Concatenation Parser function added to the TfLite Parser
Change-Id: I42a42cd765ea09a30841c66b1942b9e09a876b10
Diffstat (limited to 'src/armnnTfLiteParser/test')
-rw-r--r-- | src/armnnTfLiteParser/test/Concatenation.cpp | 187 |
1 files changed, 187 insertions, 0 deletions
diff --git a/src/armnnTfLiteParser/test/Concatenation.cpp b/src/armnnTfLiteParser/test/Concatenation.cpp new file mode 100644 index 0000000000..8629efe3d7 --- /dev/null +++ b/src/armnnTfLiteParser/test/Concatenation.cpp @@ -0,0 +1,187 @@ +// +// Copyright © 2017 Arm Ltd. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#include <boost/test/unit_test.hpp> +#include "ParserFlatbuffersFixture.hpp" +#include "../TfLiteParser.hpp" + +#include <string> +#include <iostream> + +BOOST_AUTO_TEST_SUITE(TensorflowLiteParser) + +struct ConcatenationFixture : public ParserFlatbuffersFixture +{ + explicit ConcatenationFixture(const std::string & inputShape1, + const std::string & inputShape2, + const std::string & outputShape, + const std::string & axis, + const std::string & activation="NONE") + { + m_JsonString = R"( + { + "version": 3, + "operator_codes": [ { "builtin_code": "CONCATENATION" } ], + "subgraphs": [ { + "tensors": [ + { + "shape": )" + inputShape1 + R"(, + "type": "UINT8", + "buffer": 0, + "name": "inputTensor1", + "quantization": { + "min": [ 0.0 ], + "max": [ 255.0 ], + "scale": [ 1.0 ], + "zero_point": [ 0 ], + } + }, + { + "shape": )" + inputShape2 + R"(, + "type": "UINT8", + "buffer": 1, + "name": "inputTensor2", + "quantization": { + "min": [ 0.0 ], + "max": [ 255.0 ], + "scale": [ 1.0 ], + "zero_point": [ 0 ], + } + }, + { + "shape": )" + outputShape + R"( , + "type": "UINT8", + "buffer": 2, + "name": "outputTensor", + "quantization": { + "min": [ 0.0 ], + "max": [ 255.0 ], + "scale": [ 1.0 ], + "zero_point": [ 0 ], + } + } + ], + "inputs": [ 0, 1 ], + "outputs": [ 2 ], + "operators": [ + { + "opcode_index": 0, + "inputs": [ 0, 1 ], + "outputs": [ 2 ], + "builtin_options_type": "ConcatenationOptions", + "builtin_options": { + "axis": )" + axis + R"(, + "fused_activation_function": )" + activation + R"( + }, + "custom_options_format": "FLEXBUFFERS" + } + ], + } ], + "buffers" : [ + { }, + { } + ] + } + )"; + Setup(); + } +}; + + +struct ConcatenationFixtureNegativeDim : ConcatenationFixture +{ + ConcatenationFixtureNegativeDim() : ConcatenationFixture("[ 1, 1, 2, 2 ]", + "[ 1, 1, 2, 2 ]", + "[ 1, 2, 2, 2 ]", + "-3" ) {} +}; + +BOOST_FIXTURE_TEST_CASE(ParseConcatenationNegativeDim, ConcatenationFixtureNegativeDim) +{ + RunTest<4, uint8_t>(0, + {{"inputTensor1", { 0, 1, 2, 3 }}, + {"inputTensor2", { 4, 5, 6, 7 }}}, + {{"outputTensor", { 0, 1, 2, 3, 4, 5, 6, 7 }}}); +} + +struct ConcatenationFixtureNCHW : ConcatenationFixture +{ + ConcatenationFixtureNCHW() : ConcatenationFixture("[ 1, 1, 2, 2 ]", "[ 1, 1, 2, 2 ]", "[ 1, 2, 2, 2 ]", "1" ) {} +}; + +BOOST_FIXTURE_TEST_CASE(ParseConcatenationNCHW, ConcatenationFixtureNCHW) +{ + RunTest<4, uint8_t>(0, + {{"inputTensor1", { 0, 1, 2, 3 }}, + {"inputTensor2", { 4, 5, 6, 7 }}}, + {{"outputTensor", { 0, 1, 2, 3, 4, 5, 6, 7 }}}); +} + +struct ConcatenationFixtureNHWC : ConcatenationFixture +{ + ConcatenationFixtureNHWC() : ConcatenationFixture("[ 1, 1, 2, 2 ]", "[ 1, 1, 2, 2 ]", "[ 1, 1, 2, 4 ]", "3" ) {} +}; + +BOOST_FIXTURE_TEST_CASE(ParseConcatenationNHWC, ConcatenationFixtureNHWC) +{ + RunTest<4, uint8_t>(0, + {{"inputTensor1", { 0, 1, 2, 3 }}, + {"inputTensor2", { 4, 5, 6, 7 }}}, + {{"outputTensor", { 0, 1, 4, 5, 2, 3, 6, 7 }}}); +} + +struct ConcatenationFixtureDim1 : ConcatenationFixture +{ + ConcatenationFixtureDim1() : ConcatenationFixture("[ 1, 2, 3, 4 ]", "[ 1, 2, 3, 4 ]", "[ 1, 4, 3, 4 ]", "1" ) {} +}; + +BOOST_FIXTURE_TEST_CASE(ParseConcatenationDim1, ConcatenationFixtureDim1) +{ + RunTest<4, uint8_t>(0, + { { "inputTensor1", { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 } }, + { "inputTensor2", { 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, + 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73 } } }, + { { "outputTensor", { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, + 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73 } } }); +} + +struct ConcatenationFixtureDim3 : ConcatenationFixture +{ + ConcatenationFixtureDim3() : ConcatenationFixture("[ 1, 2, 3, 4 ]", "[ 1, 2, 3, 4 ]", "[ 1, 2, 3, 8 ]", "3" ) {} +}; + +BOOST_FIXTURE_TEST_CASE(ParseConcatenationDim3, ConcatenationFixtureDim3) +{ + RunTest<4, uint8_t>(0, + { { "inputTensor1", { 0, 1, 2, 3, + 4, 5, 6, 7, + 8, 9, 10, 11, + 12, 13, 14, 15, + 16, 17, 18, 19, + 20, 21, 22, 23 } }, + { "inputTensor2", { 50, 51, 52, 53, + 54, 55, 56, 57, + 58, 59, 60, 61, + 62, 63, 64, 65, + 66, 67, 68, 69, + 70, 71, 72, 73 } } }, + { { "outputTensor", { 0, 1, 2, 3, + 50, 51, 52, 53, + 4, 5, 6, 7, + 54, 55, 56, 57, + 8, 9, 10, 11, + 58, 59, 60, 61, + 12, 13, 14, 15, + 62, 63, 64, 65, + 16, 17, 18, 19, + 66, 67, 68, 69, + 20, 21, 22, 23, + 70, 71, 72, 73 } } }); +} + +BOOST_AUTO_TEST_SUITE_END() |