6 #include <boost/test/unit_test.hpp> 8 #include "../TfLiteParser.hpp" 17 explicit ConcatenationFixture(
const std::string & inputShape1,
18 const std::string & inputShape2,
19 const std::string & outputShape,
20 const std::string & axis,
21 const std::string & activation=
"NONE")
26 "operator_codes": [ { "builtin_code": "CONCATENATION" } ], 30 "shape": )" + inputShape1 + R"(, 33 "name": "inputTensor1", 42 "shape": )" + inputShape2 + R"(, 45 "name": "inputTensor2", 54 "shape": )" + outputShape + R"( , 57 "name": "outputTensor", 73 "builtin_options_type": "ConcatenationOptions", 75 "axis": )" + axis + R"(, 76 "fused_activation_function": )" + activation + R"( 78 "custom_options_format": "FLEXBUFFERS" 93 struct ConcatenationFixtureNegativeDim : ConcatenationFixture
95 ConcatenationFixtureNegativeDim() : ConcatenationFixture(
"[ 1, 1, 2, 2 ]",
103 RunTest<4, armnn::DataType::QAsymmU8>(
105 {{
"inputTensor1", { 0, 1, 2, 3 }},
106 {
"inputTensor2", { 4, 5, 6, 7 }}},
107 {{
"outputTensor", { 0, 1, 2, 3, 4, 5, 6, 7 }}});
110 struct ConcatenationFixtureNCHW : ConcatenationFixture
112 ConcatenationFixtureNCHW() : ConcatenationFixture(
"[ 1, 1, 2, 2 ]",
"[ 1, 1, 2, 2 ]",
"[ 1, 2, 2, 2 ]",
"1" ) {}
117 RunTest<4, armnn::DataType::QAsymmU8>(
119 {{
"inputTensor1", { 0, 1, 2, 3 }},
120 {
"inputTensor2", { 4, 5, 6, 7 }}},
121 {{
"outputTensor", { 0, 1, 2, 3, 4, 5, 6, 7 }}});
124 struct ConcatenationFixtureNHWC : ConcatenationFixture
126 ConcatenationFixtureNHWC() : ConcatenationFixture(
"[ 1, 1, 2, 2 ]",
"[ 1, 1, 2, 2 ]",
"[ 1, 1, 2, 4 ]",
"3" ) {}
131 RunTest<4, armnn::DataType::QAsymmU8>(
133 {{
"inputTensor1", { 0, 1, 2, 3 }},
134 {
"inputTensor2", { 4, 5, 6, 7 }}},
135 {{
"outputTensor", { 0, 1, 4, 5, 2, 3, 6, 7 }}});
138 struct ConcatenationFixtureDim1 : ConcatenationFixture
140 ConcatenationFixtureDim1() : ConcatenationFixture(
"[ 1, 2, 3, 4 ]",
"[ 1, 2, 3, 4 ]",
"[ 1, 4, 3, 4 ]",
"1" ) {}
145 RunTest<4, armnn::DataType::QAsymmU8>(
147 { {
"inputTensor1", { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
148 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 } },
149 {
"inputTensor2", { 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
150 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73 } } },
151 { {
"outputTensor", { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
152 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
153 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,
154 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73 } } });
157 struct ConcatenationFixtureDim3 : ConcatenationFixture
159 ConcatenationFixtureDim3() : ConcatenationFixture(
"[ 1, 2, 3, 4 ]",
"[ 1, 2, 3, 4 ]",
"[ 1, 2, 3, 8 ]",
"3" ) {}
164 RunTest<4, armnn::DataType::QAsymmU8>(
166 { {
"inputTensor1", { 0, 1, 2, 3,
172 {
"inputTensor2", { 50, 51, 52, 53,
177 70, 71, 72, 73 } } },
178 { {
"outputTensor", { 0, 1, 2, 3,
189 70, 71, 72, 73 } } });
192 struct ConcatenationFixture3DDim0 : ConcatenationFixture
194 ConcatenationFixture3DDim0() : ConcatenationFixture(
"[ 1, 2, 3]",
"[ 2, 2, 3]",
"[ 3, 2, 3]",
"0" ) {}
199 RunTest<3, armnn::DataType::QAsymmU8>(
201 { {
"inputTensor1", { 0, 1, 2, 3, 4, 5 } },
202 {
"inputTensor2", { 6, 7, 8, 9, 10, 11,
203 12, 13, 14, 15, 16, 17 } } },
204 { {
"outputTensor", { 0, 1, 2, 3, 4, 5,
206 12, 13, 14, 15, 16, 17 } } });
209 struct ConcatenationFixture3DDim1 : ConcatenationFixture
211 ConcatenationFixture3DDim1() : ConcatenationFixture(
"[ 1, 2, 3]",
"[ 1, 4, 3]",
"[ 1, 6, 3]",
"1" ) {}
216 RunTest<3, armnn::DataType::QAsymmU8>(
218 { {
"inputTensor1", { 0, 1, 2, 3, 4, 5 } },
219 {
"inputTensor2", { 6, 7, 8, 9, 10, 11,
220 12, 13, 14, 15, 16, 17 } } },
221 { {
"outputTensor", { 0, 1, 2, 3, 4, 5,
223 12, 13, 14, 15, 16, 17 } } });
226 struct ConcatenationFixture3DDim2 : ConcatenationFixture
228 ConcatenationFixture3DDim2() : ConcatenationFixture(
"[ 1, 2, 3]",
"[ 1, 2, 6]",
"[ 1, 2, 9]",
"2" ) {}
233 RunTest<3, armnn::DataType::QAsymmU8>(
235 { {
"inputTensor1", { 0, 1, 2,
237 {
"inputTensor2", { 6, 7, 8, 9, 10, 11,
238 12, 13, 14, 15, 16, 17 } } },
239 { {
"outputTensor", { 0, 1, 2, 6, 7, 8, 9, 10, 11,
240 3, 4, 5, 12, 13, 14, 15, 16, 17 } } });
BOOST_AUTO_TEST_SUITE(TensorflowLiteParser)
BOOST_AUTO_TEST_SUITE_END()
BOOST_FIXTURE_TEST_CASE(ParseConcatenationNegativeDim, ConcatenationFixtureNegativeDim)