6 #include <boost/test/unit_test.hpp> 8 #include "../TfLiteParser.hpp" 17 explicit UnpackFixture(
const std::string& inputShape,
18 const unsigned int numberOfOutputs,
19 const std::string& outputShape,
20 const std::string& axis,
21 const std::string& num,
22 const std::string& dataType,
23 const std::string& outputScale,
24 const std::string& outputOffset)
27 std::string outputIndexes =
"1";
28 for(
unsigned int i = 1; i < numberOfOutputs; i++)
30 outputIndexes +=
", " + std::to_string(i+1);
35 "operator_codes": [ { "builtin_code": "UNPACK" } ], 39 "shape": )" + inputShape + R"(, 40 "type": )" + dataType + R"(, 42 "name": "inputTensor", 52 for(
unsigned int i = 0; i < numberOfOutputs; i++)
56 "shape": )" + outputShape + R"( , 57 "type": )" + dataType + R"(, 58 "buffer": )" + std::to_string(i + 1) + R"(, 59 "name": "outputTensor)" + std::to_string(i + 1) + R"(", 63 "scale": [ )" + outputScale + R"( ], 64 "zero_point": [ )" + outputOffset + R"( ], 71 "outputs": [ )" + outputIndexes + R"( ], 76 "outputs": [ )" + outputIndexes + R"( ], 77 "builtin_options_type": "UnpackOptions", 89 "custom_options_format": "FLEXBUFFERS" 103 struct DefaultUnpackAxisZeroFixture : UnpackFixture
105 DefaultUnpackAxisZeroFixture() : UnpackFixture(
"[ 4, 1, 6 ]", 4,
"[ 1, 6 ]",
"0",
"",
"FLOAT32",
"1.0",
"0") {}
108 struct DefaultUnpackAxisZeroUint8Fixture : UnpackFixture
110 DefaultUnpackAxisZeroUint8Fixture() : UnpackFixture(
"[ 4, 1, 6 ]", 4,
"[ 1, 6 ]",
"0",
"",
"UINT8",
"0.1",
"0") {}
115 RunTest<2, armnn::DataType::Float32>(
117 { {
"inputTensor", { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f,
118 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f,
119 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, 18.0f,
120 19.0f, 20.0f, 21.0f, 22.0f, 23.0f, 24.0f } } },
121 { {
"outputTensor1", { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f }},
122 {
"outputTensor2", { 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f }},
123 {
"outputTensor3", { 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, 18.0f }},
124 {
"outputTensor4", { 19.0f, 20.0f, 21.0f, 22.0f, 23.0f, 24.0f }} });
129 RunTest<2, armnn::DataType::QAsymmU8>(
131 { {
"inputTensor", { 1, 2, 3, 4, 5, 6,
133 13, 14, 15, 16, 17, 18,
134 19, 20, 21, 22, 23, 24 } } },
135 { {
"outputTensor1", { 10, 20, 30, 40, 50, 60 }},
136 {
"outputTensor2", { 70, 80, 90, 100, 110, 120 }},
137 {
"outputTensor3", { 130, 140, 150, 160, 170, 180 }},
138 {
"outputTensor4", { 190, 200, 210, 220, 230, 240 }} });
141 struct DefaultUnpackLastAxisFixture : UnpackFixture
143 DefaultUnpackLastAxisFixture() : UnpackFixture(
"[ 4, 1, 6 ]", 6,
"[ 4, 1 ]",
"2",
"6",
"FLOAT32",
"1.0",
"0") {}
146 struct DefaultUnpackLastAxisUint8Fixture : UnpackFixture
148 DefaultUnpackLastAxisUint8Fixture() : UnpackFixture(
"[ 4, 1, 6 ]", 6,
"[ 4, 1 ]",
"2",
"6",
"UINT8",
"0.1",
"0") {}
153 RunTest<2, armnn::DataType::Float32>(
155 { {
"inputTensor", { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f,
156 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f,
157 13.0f, 14.0f, 15.0f, 16.0f, 17.0f, 18.0f,
158 19.0f, 20.0f, 21.0f, 22.0f, 23.0f, 24.0f } } },
159 { {
"outputTensor1", { 1.0f, 7.0f, 13.0f, 19.0f }},
160 {
"outputTensor2", { 2.0f, 8.0f, 14.0f, 20.0f }},
161 {
"outputTensor3", { 3.0f, 9.0f, 15.0f, 21.0f }},
162 {
"outputTensor4", { 4.0f, 10.0f, 16.0f, 22.0f }},
163 {
"outputTensor5", { 5.0f, 11.0f, 17.0f, 23.0f }},
164 {
"outputTensor6", { 6.0f, 12.0f, 18.0f, 24.0f }} });
168 RunTest<2, armnn::DataType::QAsymmU8>(
170 {{
"inputTensor", { 1, 2, 3, 4, 5, 6,
172 13, 14, 15, 16, 17, 18,
173 19, 20, 21, 22, 23, 24 }}},
174 {{
"outputTensor1", { 10, 70, 130, 190 }},
175 {
"outputTensor2", { 20, 80, 140, 200 }},
176 {
"outputTensor3", { 30, 90, 150, 210 }},
177 {
"outputTensor4", { 40, 100, 160, 220 }},
178 {
"outputTensor5", { 50, 110, 170, 230 }},
179 {
"outputTensor6", { 60, 120, 180, 240 }}});
BOOST_AUTO_TEST_SUITE(TensorflowLiteParser)
BOOST_FIXTURE_TEST_CASE(UnpackAxisZeroNumIsDefaultNotSpecified, DefaultUnpackAxisZeroFixture)
BOOST_AUTO_TEST_SUITE_END()