6 #include <boost/test/unit_test.hpp> 8 #include "../TfLiteParser.hpp" 17 explicit DivFixture(
const std::string & inputShape1,
18 const std::string & inputShape2,
19 const std::string & outputShape,
20 const std::string & activation=
"NONE")
25 "operator_codes": [ { "builtin_code": "DIV" } ], 29 "shape": )" + inputShape1 + R"(, 32 "name": "inputTensor1", 41 "shape": )" + inputShape2 + R"(, 44 "name": "inputTensor2", 53 "shape": )" + outputShape + R"( , 56 "name": "outputTensor", 72 "builtin_options_type": "DivOptions", 74 "fused_activation_function": )" + activation + R"( 76 "custom_options_format": "FLEXBUFFERS" 90 struct SimpleDivFixture :
public DivFixture
92 SimpleDivFixture() : DivFixture(
"[ 1, 2, 2, 3 ]",
"[ 1, 2, 2, 3 ]",
"[ 1, 2, 2, 3 ]") {}
98 float Inf = std::numeric_limits<float>::infinity();
99 float NaN = std::numeric_limits<float>::quiet_NaN();
101 RunTest<4, DataType::Float32>(0, {{
"inputTensor1", { 0.0f, 1.0f, 2.0f,
104 9.0f, 10.0f, -11.0f } },
105 {
"inputTensor2", { 0.0f, 0.0f, 4.0f,
108 9.0f, 10.0f, 11.0f} } },
109 {{
"outputTensor", { NaN, Inf, 0.5f,
112 1.0f, 1.0f, -1.0f } } });
116 struct DynamicDivFixture :
public DivFixture
118 DynamicDivFixture() : DivFixture(
"[ 1, 2, 2, 3 ]",
"[ 1, 2, 2, 3 ]",
"[ ]") {}
124 float Inf = std::numeric_limits<float>::infinity();
125 float NaN = std::numeric_limits<float>::quiet_NaN();
127 RunTest<4, DataType::Float32, DataType::Float32>(0, {{
"inputTensor1", { 0.0f, 1.0f, 2.0f,
130 9.0f, 10.0f, -11.0f } },
131 {
"inputTensor2", { 0.0f, 0.0f, 4.0f,
134 9.0f, 10.0f, 11.0f} } },
135 {{
"outputTensor", { NaN, Inf, 0.5f,
138 1.0f, 1.0f, -1.0f } } },
true);
BOOST_AUTO_TEST_SUITE(TensorflowLiteParser)
BOOST_FIXTURE_TEST_CASE(ParseDiv, SimpleDivFixture)
BOOST_AUTO_TEST_SUITE_END()