6 #include <boost/test/unit_test.hpp> 8 #include "../TfLiteParser.hpp" 16 explicit ElementWiseUnaryFixture(
const std::string& operatorCode,
17 const std::string& dataType,
18 const std::string& inputShape,
19 const std::string& outputShape)
24 "operator_codes": [ { "builtin_code": )" + operatorCode + R"( } ], 28 "shape": )" + inputShape + R"(, 29 "type": )" + dataType + R"( , 31 "name": "inputTensor", 40 "shape": )" + outputShape + R"( , 41 "type": )" + dataType + R"( , 43 "name": "outputTensor", 59 "custom_options_format": "FLEXBUFFERS" 73 struct SimpleAbsFixture :
public ElementWiseUnaryFixture
75 SimpleAbsFixture() : ElementWiseUnaryFixture(
"ABS",
"FLOAT32",
"[ 2, 2 ]",
"[ 2, 2 ]") {}
80 std::vector<float> inputValues
87 std::vector<float> expectedOutputValues(inputValues.size());
88 for (
unsigned int i = 0; i < inputValues.size(); ++i)
90 expectedOutputValues[i] = std::abs(inputValues[i]);
93 RunTest<2, armnn::DataType::Float32>(0, {{
"inputTensor", { inputValues } }},
94 {{
"outputTensor",{ expectedOutputValues } } });
97 struct SimpleExpFixture :
public ElementWiseUnaryFixture
99 SimpleExpFixture() : ElementWiseUnaryFixture(
"EXP",
"FLOAT32",
"[ 1, 2, 3, 1 ]",
"[ 1, 2, 3, 1 ]") {}
104 RunTest<4, armnn::DataType::Float32>(0, {{
"inputTensor", { 0.0f, 1.0f, 2.0f,
105 3.0f, 4.0f, 5.0f} }},
106 {{
"outputTensor",{ 1.0f, 2.718281f, 7.3890515f,
107 20.0855185f, 54.5980834f, 148.4129329f} } });
110 struct SimpleLogicalNotFixture :
public ElementWiseUnaryFixture
112 SimpleLogicalNotFixture() : ElementWiseUnaryFixture(
"LOGICAL_NOT",
"BOOL",
"[ 1, 1, 1, 4 ]",
"[ 1, 1, 1, 4 ]") {}
117 RunTest<4, armnn::DataType::Boolean>(0, {{
"inputTensor", { 0, 1, 0, 1 } }},
118 {{
"outputTensor",{ 1, 0, 1, 0 } } });
121 struct SimpleNegFixture :
public ElementWiseUnaryFixture
123 SimpleNegFixture() : ElementWiseUnaryFixture(
"NEG",
"FLOAT32",
"[ 1, 2, 3, 1 ]",
"[ 1, 2, 3, 1 ]") {}
128 RunTest<4, armnn::DataType::Float32>(0, {{
"inputTensor", { 0.0f, 1.0f, -2.0f,
129 20.0855185f, -54.5980834f, 5.0f} }},
130 {{
"outputTensor",{ 0.0f, -1.0f, 2.0f,
131 -20.0855185f, 54.5980834f, -5.0f} }});
134 struct SimpleRsqrtFixture :
public ElementWiseUnaryFixture
136 SimpleRsqrtFixture() : ElementWiseUnaryFixture(
"RSQRT",
"FLOAT32",
"[ 1, 2, 3, 1 ]",
"[ 1, 2, 3, 1 ]") {}
141 RunTest<4, armnn::DataType::Float32>(0, {{
"inputTensor", { 1.0f, 4.0f, 16.0f,
142 25.0f, 64.0f, 100.0f } }},
143 {{
"outputTensor",{ 1.0f, 0.5f, 0.25f,
144 0.2f, 0.125f, 0.1f} }});
BOOST_AUTO_TEST_SUITE(TensorflowLiteParser)
BOOST_FIXTURE_TEST_CASE(ParseAbs, SimpleAbsFixture)
BOOST_AUTO_TEST_SUITE_END()