6 #include <boost/test/unit_test.hpp> 8 #include "../TfLiteParser.hpp" 17 explicit SpaceToBatchNDFixture(
const std::string & inputShape,
18 const std::string & outputShape,
19 const std::string & blockShapeData,
20 const std::string & padListData)
25 "operator_codes": [ { "builtin_code": "SPACE_TO_BATCH_ND" } ], 29 "shape": )" + inputShape + R"(, 32 "name": "inputTensor", 41 "shape": )" + outputShape + R"(, 44 "name": "outputTensor", 56 "name": "blockShapeTensor", 68 "name": "padListTensor", 82 "inputs": [ 0, 2, 3 ], 84 "custom_options_format": "FLEXBUFFERS" 91 { "data": )" + blockShapeData + R"(, }, 92 { "data": )" + padListData + R"(, }, 100 struct SpaceToBatchNDFixtureSimpleTest :
public SpaceToBatchNDFixture
102 SpaceToBatchNDFixtureSimpleTest() : SpaceToBatchNDFixture(
"[ 1, 4, 4, 1 ]",
104 "[ 2,0,0,0, 2,0,0,0 ]",
105 "[ 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0 ]") {}
110 RunTest<4, armnn::DataType::Float32>
112 {{
"inputTensor", { 1.0f, 2.0f, 3.0f, 4.0f,
113 5.0f, 6.0f, 7.0f, 8.0f,
114 9.0f, 10.0f, 11.0f, 12.0f,
115 13.0f, 14.0f, 15.0f, 16.0f }}},
116 {{
"outputTensor", { 1.0f, 3.0f, 9.0f, 11.0f,
117 2.0f, 4.0f, 10.0f, 12.0f,
118 5.0f, 7.0f, 13.0f, 15.0f,
119 6.0f, 8.0f, 14.0f, 16.0f }}});
123 struct SpaceToBatchNDFixtureMultipleInputBatchesTest :
public SpaceToBatchNDFixture
125 SpaceToBatchNDFixtureMultipleInputBatchesTest() : SpaceToBatchNDFixture(
"[ 2, 2, 4, 1 ]",
127 "[ 2,0,0,0, 2,0,0,0 ]",
128 "[ 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0 ]") {}
133 RunTest<4, armnn::DataType::Float32>
135 {{
"inputTensor", { 1.0f, 2.0f, 3.0f, 4.0f,
136 5.0f, 6.0f, 7.0f, 8.0f,
137 9.0f, 10.0f, 11.0f, 12.0f,
138 13.0f, 14.0f, 15.0f, 16.0f }}},
139 {{
"outputTensor", { 1.0f, 3.0f, 9.0f, 11.0f,
140 2.0f, 4.0f, 10.0f, 12.0f,
141 5.0f, 7.0f, 13.0f, 15.0f,
142 6.0f, 8.0f, 14.0f, 16.0f }}});
145 struct SpaceToBatchNDFixturePaddingTest :
public SpaceToBatchNDFixture
147 SpaceToBatchNDFixturePaddingTest() : SpaceToBatchNDFixture(
"[ 1, 5, 2, 1 ]",
149 "[ 3,0,0,0, 2,0,0,0 ]",
150 "[ 1,0,0,0, 0,0,0,0, 2,0,0,0, 0,0,0,0 ]") {}
155 RunTest<4, armnn::DataType::Float32>
157 {{
"inputTensor", { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f,
158 6.0f, 7.0f, 8.0f, 9.0f, 10.0f }}},
159 {{
"outputTensor", { 0.0f, 0.0f,
BOOST_AUTO_TEST_SUITE(TensorflowLiteParser)
BOOST_FIXTURE_TEST_CASE(SpaceToBatchNdSimpleTest, SpaceToBatchNDFixtureSimpleTest)
BOOST_AUTO_TEST_SUITE_END()