5 #include <boost/test/unit_test.hpp> 7 #include "../TfLiteParser.hpp" 16 explicit GetInputsOutputsMainFixture(
const std::string& inputs,
const std::string& outputs)
21 "operator_codes": [ { "builtin_code": "AVERAGE_POOL_2D" }, { "builtin_code": "CONV_2D" } ], 26 "shape": [ 1, 1, 1, 1 ] , 29 "name": "OutputTensor", 38 "shape": [ 1, 2, 2, 1 ] , 41 "name": "InputTensor", 60 "builtin_options_type": "Pool2DOptions", 68 "fused_activation_function": "NONE" 70 "custom_options_format": "FLEXBUFFERS" 76 "shape": [ 1, 3, 3, 1 ], 79 "name": "ConvInputTensor", 86 "shape": [ 1, 1, 1, 1 ], 89 "name": "ConvOutputTensor", 98 "shape": [ 1, 3, 3, 1 ], 101 "name": "filterTensor", 117 "builtin_options_type": "Conv2DOptions", 122 "fused_activation_function": "NONE" 124 "custom_options_format": "FLEXBUFFERS" 129 "description": "Test Subgraph Inputs Outputs", 133 { "data": [ 2,1,0, 6,2,1, 4,1,2 ], }, 143 struct GetEmptyInputsOutputsFixture : GetInputsOutputsMainFixture
145 GetEmptyInputsOutputsFixture() : GetInputsOutputsMainFixture(
"[ ]",
"[ ]") {}
148 struct GetInputsOutputsFixture : GetInputsOutputsMainFixture
150 GetInputsOutputsFixture() : GetInputsOutputsMainFixture(
"[ 1 ]",
"[ 0 ]") {}
156 m_GraphBinary.size());
158 BOOST_CHECK_EQUAL(0, tensors.size());
164 m_GraphBinary.size());
166 BOOST_CHECK_EQUAL(0, tensors.size());
172 m_GraphBinary.size());
174 BOOST_CHECK_EQUAL(1, tensors.size());
175 CheckTensors(tensors[0], 4, { 1, 2, 2, 1 }, tflite::TensorType::TensorType_UINT8, 1,
176 "InputTensor", { -1.2f }, { 25.5f }, { 0.25f }, { 10 });
182 m_GraphBinary.size());
184 BOOST_CHECK_EQUAL(1, tensors.size());
185 CheckTensors(tensors[0], 4, { 1, 1, 1, 1 }, tflite::TensorType::TensorType_UINT8, 0,
186 "OutputTensor", { 0.0f }, { 255.0f }, { 1.0f }, { 0 });
192 m_GraphBinary.size());
194 BOOST_CHECK_EQUAL(2, tensors.size());
195 CheckTensors(tensors[0], 4, { 1, 3, 3, 1 }, tflite::TensorType::TensorType_UINT8, 0,
196 "ConvInputTensor", { }, { }, { 1.0f }, { 0 });
197 CheckTensors(tensors[1], 4, { 1, 3, 3, 1 }, tflite::TensorType::TensorType_UINT8, 2,
198 "filterTensor", { 0.0f }, { 255.0f }, { 1.0f }, { 0 });
204 m_GraphBinary.size());
206 BOOST_CHECK_EQUAL(1, tensors.size());
207 CheckTensors(tensors[0], 4, { 1, 1, 1, 1 }, tflite::TensorType::TensorType_UINT8, 1,
208 "ConvOutputTensor", { 0.0f }, { 511.0f }, { 2.0f }, { 0 });
224 m_GraphBinary.size());
231 m_GraphBinary.size());
238 m_GraphBinary.size());
245 m_GraphBinary.size());
BOOST_AUTO_TEST_SUITE(TensorflowLiteParser)
bool ReadStringToBinary()
std::vector< TensorRawPtr > TensorRawPtrVector
BOOST_AUTO_TEST_SUITE_END()