6 #include <boost/test/unit_test.hpp> 8 #include "../TfLiteParser.hpp" 17 explicit PadFixture(
const std::string& inputShape,
18 const std::string& outputShape,
19 const std::string& padListShape,
20 const std::string& padListData,
21 const std::string& dataType =
"FLOAT32",
22 const std::string& scale =
"1.0",
23 const std::string& offset =
"0")
28 "operator_codes": [ { "builtin_code": "PAD" } ], 32 "shape": )" + inputShape + R"(, 33 "type": )" + dataType + R"(, 35 "name": "inputTensor", 39 "scale": [ )" + scale + R"( ], 40 "zero_point": [ )" + offset + R"( ], 44 "shape": )" + outputShape + R"(, 45 "type": )" + dataType + R"(, 47 "name": "outputTensor", 51 "scale": [ )" + scale + R"( ], 52 "zero_point": [ )" + offset + R"( ], 56 "shape": )" + padListShape + R"( , 75 "custom_options_format": "FLEXBUFFERS" 82 { "data": )" + padListData + R"(, }, 90 struct SimplePadFixture :
public PadFixture
92 SimplePadFixture() : PadFixture(
"[ 2, 3 ]",
"[ 4, 7 ]",
"[ 2, 2 ]",
93 "[ 1,0,0,0, 1,0,0,0, 2,0,0,0, 2,0,0,0 ]") {}
98 RunTest<2, armnn::DataType::Float32>
100 {{
"inputTensor", { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f }}},
101 {{
"outputTensor", { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
102 0.0f, 0.0f, 1.0f, 2.0f, 3.0f, 0.0f, 0.0f,
103 0.0f, 0.0f, 4.0f, 5.0f, 6.0f, 0.0f, 0.0f,
104 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }}});
107 struct Uint8PadFixture :
public PadFixture
109 Uint8PadFixture() : PadFixture(
"[ 2, 3 ]",
"[ 4, 7 ]",
"[ 2, 2 ]",
110 "[ 1,0,0,0, 1,0,0,0, 2,0,0,0, 2,0,0,0 ]",
111 "UINT8",
"-2.0",
"3") {}
116 RunTest<2, armnn::DataType::QAsymmU8>
118 {{
"inputTensor", { 1, 2, 3, 4, 5, 6 }}},
119 {{
"outputTensor", { 3, 3, 3, 3, 3, 3, 3,
122 3, 3, 3, 3, 3, 3, 3 }}});
125 struct Int8PadFixture :
public PadFixture
127 Int8PadFixture() : PadFixture(
"[ 2, 3 ]",
"[ 4, 7 ]",
"[ 2, 2 ]",
128 "[ 1,0,0,0, 1,0,0,0, 2,0,0,0, 2,0,0,0 ]",
129 "INT8",
"-2.0",
"3") {}
134 RunTest<2, armnn::DataType::QAsymmS8>
136 {{
"inputTensor", { 1, -2, 3, 4, 5, -6 }}},
137 {{
"outputTensor", { 3, 3, 3, 3, 3, 3, 3,
138 3, 3, 1, -2, 3, 3, 3,
139 3, 3, 4, 5, -6, 3, 3,
140 3, 3, 3, 3, 3, 3, 3 }}});
BOOST_AUTO_TEST_SUITE(TensorflowLiteParser)
BOOST_AUTO_TEST_SUITE_END()
void SetupSingleInputSingleOutput(const std::string &inputName, const std::string &outputName)
BOOST_FIXTURE_TEST_CASE(ParsePad, SimplePadFixture)