5 #include <boost/test/unit_test.hpp> 7 #include "../TfLiteParser.hpp" 17 explicit GetSubgraphInputsOutputsMainFixture(
const std::string& inputs,
const std::string& outputs)
22 "operator_codes": [ { "builtin_code": "AVERAGE_POOL_2D" }, { "builtin_code": "CONV_2D" } ], 27 "shape": [ 1, 1, 1, 1 ] , 30 "name": "OutputTensor", 39 "shape": [ 1, 2, 2, 1 ] , 42 "name": "InputTensor", 61 "builtin_options_type": "Pool2DOptions", 69 "fused_activation_function": "NONE" 71 "custom_options_format": "FLEXBUFFERS" 77 "shape": [ 1, 3, 3, 1 ], 80 "name": "ConvInputTensor", 87 "shape": [ 1, 1, 1, 1 ], 90 "name": "ConvOutputTensor", 99 "shape": [ 1, 3, 3, 1 ], 102 "name": "filterTensor", 118 "builtin_options_type": "Conv2DOptions", 123 "fused_activation_function": "NONE" 125 "custom_options_format": "FLEXBUFFERS" 130 "description": "Test Subgraph Inputs Outputs", 134 { "data": [ 2,1,0, 6,2,1, 4,1,2 ], }, 144 struct GetEmptySubgraphInputsOutputsFixture : GetSubgraphInputsOutputsMainFixture
146 GetEmptySubgraphInputsOutputsFixture() : GetSubgraphInputsOutputsMainFixture(
"[ ]",
"[ ]") {}
149 struct GetSubgraphInputsOutputsFixture : GetSubgraphInputsOutputsMainFixture
151 GetSubgraphInputsOutputsFixture() : GetSubgraphInputsOutputsMainFixture(
"[ 1 ]",
"[ 0 ]") {}
157 m_GraphBinary.size());
158 TfLiteParserImpl::TensorIdRawPtrVector subgraphTensors = TfLiteParserImpl::GetSubgraphInputs(model, 0);
159 BOOST_CHECK_EQUAL(0, subgraphTensors.size());
165 m_GraphBinary.size());
166 TfLiteParserImpl::TensorIdRawPtrVector subgraphTensors = TfLiteParserImpl::GetSubgraphOutputs(model, 0);
167 BOOST_CHECK_EQUAL(0, subgraphTensors.size());
173 m_GraphBinary.size());
174 TfLiteParserImpl::TensorIdRawPtrVector subgraphTensors = TfLiteParserImpl::GetSubgraphInputs(model, 0);
175 BOOST_CHECK_EQUAL(1, subgraphTensors.size());
176 BOOST_CHECK_EQUAL(1, subgraphTensors[0].first);
177 CheckTensors(subgraphTensors[0].second, 4, { 1, 2, 2, 1 }, tflite::TensorType::TensorType_UINT8, 1,
178 "InputTensor", { -1.2f }, { 25.5f }, { 0.25f }, { 10 });
184 m_GraphBinary.size());
185 TfLiteParserImpl::TensorIdRawPtrVector subgraphTensors = TfLiteParserImpl::GetSubgraphOutputs(model, 0);
186 BOOST_CHECK_EQUAL(1, subgraphTensors.size());
187 BOOST_CHECK_EQUAL(0, subgraphTensors[0].first);
188 CheckTensors(subgraphTensors[0].second, 4, { 1, 1, 1, 1 }, tflite::TensorType::TensorType_UINT8, 0,
189 "OutputTensor", { 0.0f }, { 255.0f }, { 1.0f }, { 0 });
195 m_GraphBinary.size());
196 TfLiteParserImpl::TensorIdRawPtrVector subgraphTensors = TfLiteParserImpl::GetSubgraphInputs(model, 1);
197 BOOST_CHECK_EQUAL(1, subgraphTensors.size());
198 BOOST_CHECK_EQUAL(0, subgraphTensors[0].first);
199 CheckTensors(subgraphTensors[0].second, 4, { 1, 3, 3, 1 }, tflite::TensorType::TensorType_UINT8, 0,
200 "ConvInputTensor", { }, { }, { 1.0f }, { 0 });
206 m_GraphBinary.size());
207 TfLiteParserImpl::TensorIdRawPtrVector subgraphTensors = TfLiteParserImpl::GetSubgraphOutputs(model, 1);
208 BOOST_CHECK_EQUAL(1, subgraphTensors.size());
209 BOOST_CHECK_EQUAL(1, subgraphTensors[0].first);
210 CheckTensors(subgraphTensors[0].second, 4, { 1, 1, 1, 1 }, tflite::TensorType::TensorType_UINT8, 1,
211 "ConvOutputTensor", { 0.0f }, { 511.0f }, { 2.0f }, { 0 });
227 m_GraphBinary.size());
234 m_GraphBinary.size());
BOOST_AUTO_TEST_SUITE(TensorflowLiteParser)
bool ReadStringToBinary()
armnnSerializer::TensorInfo * TensorRawPtr
BOOST_AUTO_TEST_SUITE_END()