6 #include <boost/assert.hpp> 7 #include <boost/test/unit_test.hpp> 20 AddNFixture(
const std::vector<armnn::TensorShape> inputShapes,
unsigned int numberOfInputs)
22 BOOST_ASSERT(inputShapes.size() == numberOfInputs);
24 for (
unsigned int i = 0; i < numberOfInputs; i++)
26 m_Prototext.append(
"node { \n");
27 m_Prototext.append(
" name: \"input").append(std::to_string(i)).append(
"\"\n");
28 m_Prototext += R
"( op: "Placeholder" 45 m_Prototext += R"(node { 49 for (
unsigned int i = 0; i < numberOfInputs; i++)
51 m_Prototext.append(
" input: \"input").append(std::to_string(i)).append(
"\"\n");
53 m_Prototext += R
"( attr { 57 m_Prototext.append(" i: ").append(std::to_string(numberOfInputs)).append(
"\n");
68 std::map<std::string, armnn::TensorShape> inputs; 69 for (
unsigned int i = 0; i < numberOfInputs; i++)
71 std::string name(
"input");
72 name.append(std::to_string(i));
73 inputs.emplace(std::make_pair(name, inputShapes[i]));
75 Setup(inputs, {
"output"});
81 struct FiveTwoDimInputsFixture : AddNFixture
83 FiveTwoDimInputsFixture() : AddNFixture({ { 2, 2 }, { 2, 2 }, { 2, 2 }, { 2, 2 }, { 2, 2 } }, 5) {}
89 RunTest<2>({ {
"input0", { 1.0, 2.0, 3.0, 4.0 } },
90 {
"input1", { 1.0, 5.0, 2.0, 2.0 } },
91 {
"input2", { 1.0, 1.0, 2.0, 2.0 } },
92 {
"input3", { 3.0, 7.0, 1.0, 2.0 } },
93 {
"input4", { 8.0, 0.0, -2.0, -3.0 } } },
94 { {
"output", { 14.0, 15.0, 6.0, 7.0 } } });
97 struct TwoTwoDimInputsFixture : AddNFixture
99 TwoTwoDimInputsFixture() : AddNFixture({ { 2, 2 }, { 2, 2 } }, 2) {}
104 RunTest<2>({ {
"input0", { 1.0, 2.0, 3.0, 4.0 } },
105 {
"input1", { 1.0, 5.0, 2.0, 2.0 } } },
106 { {
"output", { 2.0, 7.0, 5.0, 6.0 } } });
109 struct ThreeTwoDimInputsFixture : AddNFixture
111 ThreeTwoDimInputsFixture() : AddNFixture({ { 2, 2 }, { 2, 2 }, { 2, 2 } }, 3) {}
116 RunTest<2>({ {
"input0", { 1.0, 2.0, 3.0, 4.0 } },
117 {
"input1", { 1.0, 5.0, 2.0, 2.0 } },
118 {
"input2", { 1.0, 1.0, 2.0, 2.0 } } },
119 { {
"output", { 3.0, 8.0, 7.0, 8.0 } } });
122 struct EightTwoDimInputsFixture : AddNFixture
124 EightTwoDimInputsFixture() : AddNFixture({ { 2, 2 }, { 2, 2 }, { 2, 2 }, { 2, 2 },
125 { 2, 2 }, { 2, 2 }, { 2, 2 }, { 2, 2 } }, 8) {}
130 RunTest<2>({ {
"input0", { 1.0, 2.0, 3.0, 4.0 } },
131 {
"input1", { 1.0, 5.0, 2.0, 2.0 } },
132 {
"input2", { 1.0, 1.0, 2.0, 2.0 } },
133 {
"input3", { 3.0, 7.0, 1.0, 2.0 } },
134 {
"input4", { 8.0, 0.0, -2.0, -3.0 } },
135 {
"input5", {-3.0, 2.0, -1.0, -5.0 } },
136 {
"input6", { 1.0, 6.0, 2.0, 2.0 } },
137 {
"input7", {-19.0, 7.0, 1.0, -10.0 } } },
138 { {
"output", {-7.0, 30.0, 8.0, -6.0 } } });
141 struct ThreeInputBroadcast1D4D4DInputsFixture : AddNFixture
143 ThreeInputBroadcast1D4D4DInputsFixture() : AddNFixture({ { 1 }, { 1, 1, 2, 2 }, { 1, 1, 2, 2 } }, 3) {}
148 RunTest<4>({ {
"input0", { 1.0 } },
149 {
"input1", { 1.0, 5.0, 2.0, 2.0 } },
150 {
"input2", { 1.0, 1.0, 2.0, 2.0 } } },
151 { {
"output", { 3.0, 7.0, 5.0, 5.0 } } });
154 struct ThreeInputBroadcast4D1D4DInputsFixture : AddNFixture
156 ThreeInputBroadcast4D1D4DInputsFixture() : AddNFixture({ { 1, 1, 2, 2 }, { 1 }, { 1, 1, 2, 2 } }, 3) {}
161 RunTest<4>({ {
"input0", { 1.0, 3.0, 9.0, 4.0 } },
162 {
"input1", {-2.0 } },
163 {
"input2", { 1.0, 1.0, 2.0, 2.0 } } },
164 { {
"output", { 0.0, 2.0, 9.0, 4.0 } } });
167 struct ThreeInputBroadcast4D4D1DInputsFixture : AddNFixture
169 ThreeInputBroadcast4D4D1DInputsFixture() : AddNFixture({ { 1, 1, 2, 2 }, { 1, 1, 2, 2 }, { 1 } }, 3) {}
174 RunTest<4>({ {
"input0", { 1.0, 5.0, 2.0, 2.0 } },
175 {
"input1", { 1.0, 1.0, 2.0, 2.0 } },
176 {
"input2", { 1.0 } } },
177 { {
"output", { 3.0, 7.0, 5.0, 5.0 } } });
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_SUITE(TensorflowLiteParser)
BOOST_FIXTURE_TEST_CASE(FiveTwoDimInputs, FiveTwoDimInputsFixture)