6 #include <boost/test/unit_test.hpp> 8 #include "../TfLiteParser.hpp" 17 explicit SplitVFixture(
const std::string& inputShape,
18 const std::string& splitValues,
19 const std::string& sizeSplitsShape,
20 const std::string& axisShape,
21 const std::string& numSplits,
22 const std::string& outputShape1,
23 const std::string& outputShape2,
24 const std::string& axisData,
25 const std::string& dataType)
30 "operator_codes": [ { "builtin_code": "SPLIT_V" } ], 34 "shape": )" + inputShape + R"(, 35 "type": )" + dataType + R"(, 37 "name": "inputTensor", 46 "shape": )" + sizeSplitsShape + R"(, 58 "shape": )" + axisShape + R"(, 70 "shape": )" + outputShape1 + R"( , 71 "type":)" + dataType + R"(, 73 "name": "outputTensor1", 82 "shape": )" + outputShape2 + R"( , 83 "type":)" + dataType + R"(, 85 "name": "outputTensor2", 94 "inputs": [ 0, 1, 2 ], 99 "inputs": [ 0, 1, 2 ], 101 "builtin_options_type": "SplitVOptions", 103 "num_splits": )" + numSplits + R"( 105 "custom_options_format": "FLEXBUFFERS" 109 "buffers" : [ {}, { "data": )" + splitValues + R"( }, { "data": )" + axisData + R"( }, {}, {}] 121 struct SimpleSplitVAxisOneFixture : SplitVFixture
123 SimpleSplitVAxisOneFixture()
124 : SplitVFixture(
"[ 4, 2, 2, 2 ]",
"[ 1, 0, 0, 0, 3, 0, 0, 0 ]",
"[ 2 ]",
"[ ]",
"2",
125 "[ 1, 2, 2, 2 ]",
"[ 3, 2, 2, 2 ]",
"[ 0, 0, 0, 0 ]",
"FLOAT32")
131 RunTest<4, armnn::DataType::Float32>(
133 { {
"inputTensor", { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f,
134 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f,
135 17.0f, 18.0f, 19.0f, 20.0f, 21.0f, 22.0f, 23.0f, 24.0f,
136 25.0f, 26.0f, 27.0f, 28.0f, 29.0f, 30.0f, 31.0f, 32.0f } } },
137 { {
"outputTensor1", { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f } },
138 {
"outputTensor2", { 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f,
139 17.0f, 18.0f, 19.0f, 20.0f, 21.0f, 22.0f, 23.0f, 24.0f,
140 25.0f, 26.0f, 27.0f, 28.0f, 29.0f, 30.0f, 31.0f, 32.0f } } } );
143 struct SimpleSplitVAxisTwoFixture : SplitVFixture
145 SimpleSplitVAxisTwoFixture()
146 : SplitVFixture(
"[ 2, 4, 2, 2 ]",
"[ 3, 0, 0, 0, 1, 0, 0, 0 ]",
"[ 2 ]",
"[ ]",
"2",
147 "[ 2, 3, 2, 2 ]",
"[ 2, 1, 2, 2 ]",
"[ 1, 0, 0, 0 ]",
"FLOAT32")
153 RunTest<4, armnn::DataType::Float32>(
155 { {
"inputTensor", { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f,
156 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f,
157 17.0f, 18.0f, 19.0f, 20.0f, 21.0f, 22.0f, 23.0f, 24.0f,
158 25.0f, 26.0f, 27.0f, 28.0f, 29.0f, 30.0f, 31.0f, 32.0f } } },
159 { {
"outputTensor1", { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f,
160 9.0f, 10.0f, 11.0f, 12.0f, 17.0f, 18.0f, 19.0f, 20.0f,
161 21.0f, 22.0f, 23.0f, 24.0f, 25.0f, 26.0f, 27.0f, 28.0f } },
162 {
"outputTensor2", { 13.0f, 14.0f, 15.0f, 16.0f, 29.0f, 30.0f, 31.0f, 32.0f } } } );
165 struct SimpleSplitVAxisThreeFixture : SplitVFixture
167 SimpleSplitVAxisThreeFixture()
168 : SplitVFixture(
"[ 2, 2, 4, 2 ]",
"[ 1, 0, 0, 0, 3, 0, 0, 0 ]",
"[ 2 ]",
"[ ]",
"2",
169 "[ 2, 2, 1, 2 ]",
"[ 2, 2, 3, 2 ]",
"[ 2, 0, 0, 0 ]",
"FLOAT32")
175 RunTest<4, armnn::DataType::Float32>(
177 { {
"inputTensor", { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f,
178 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f,
179 17.0f, 18.0f, 19.0f, 20.0f, 21.0f, 22.0f, 23.0f, 24.0f,
180 25.0f, 26.0f, 27.0f, 28.0f, 29.0f, 30.0f, 31.0f, 32.0f } } },
181 { {
"outputTensor1", { 1.0f, 2.0f, 9.0f, 10.0f, 17.0f, 18.0f, 25.0f, 26.0f } },
182 {
"outputTensor2", { 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 11.0f, 12.0f,
183 13.0f, 14.0f, 15.0f, 16.0f, 19.0f, 20.0f, 21.0f, 22.0f,
184 23.0f, 24.0f, 27.0f, 28.0f, 29.0f, 30.0f, 31.0f, 32.0f } } } );
187 struct SimpleSplitVAxisFourFixture : SplitVFixture
189 SimpleSplitVAxisFourFixture()
190 : SplitVFixture(
"[ 2, 2, 2, 4 ]",
"[ 3, 0, 0, 0, 1, 0, 0, 0 ]",
"[ 2 ]",
"[ ]",
"2",
191 "[ 2, 2, 2, 3 ]",
"[ 2, 2, 2, 1 ]",
"[ 3, 0, 0, 0 ]",
"FLOAT32")
197 RunTest<4, armnn::DataType::Float32>(
199 { {
"inputTensor", { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f,
200 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f,
201 17.0f, 18.0f, 19.0f, 20.0f, 21.0f, 22.0f, 23.0f, 24.0f,
202 25.0f, 26.0f, 27.0f, 28.0f, 29.0f, 30.0f, 31.0f, 32.0f } } },
203 { {
"outputTensor1", { 1.0f, 2.0f, 3.0f, 5.0f, 6.0f, 7.0f, 9.0f, 10.0f,
204 11.0f, 13.0f, 14.0f, 15.0f, 17.0f, 18.0f, 19.0f, 21.0f,
205 22.0f, 23.0f, 25.0f, 26.0f, 27.0f, 29.0f, 30.0f, 31.0f} },
206 {
"outputTensor2", { 4.0f, 8.0f, 12.0f, 16.0f, 20.0f, 24.0f, 28.0f, 32.0f } } } );
BOOST_AUTO_TEST_SUITE(TensorflowLiteParser)
BOOST_FIXTURE_TEST_CASE(ParseAxisOneSplitVTwo, SimpleSplitVAxisOneFixture)
BOOST_AUTO_TEST_SUITE_END()