5 #include <boost/test/unit_test.hpp> 7 #include "../TfLiteParser.hpp" 16 explicit GetTensorIdsFixture(
const std::string& inputs,
const std::string& outputs)
21 "operator_codes": [ { "builtin_code": "AVERAGE_POOL_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" 74 "description": "Test loading a model", 75 "buffers" : [ {}, {} ] 82 struct GetEmptyTensorIdsFixture : GetTensorIdsFixture
84 GetEmptyTensorIdsFixture() : GetTensorIdsFixture(
"[ ]",
"[ ]") {}
87 struct GetInputOutputTensorIdsFixture : GetTensorIdsFixture
89 GetInputOutputTensorIdsFixture() : GetTensorIdsFixture(
"[ 0, 1, 2 ]",
"[ 3 ]") {}
94 TfLiteParser::ModelPtr model = TfLiteParser::LoadModelFromBinary(m_GraphBinary.data(), m_GraphBinary.size());
95 std::vector<int32_t> expectedIds = { };
96 std::vector<int32_t> inputTensorIds = TfLiteParser::GetInputTensorIds(model, 0, 0);
97 BOOST_CHECK_EQUAL_COLLECTIONS(expectedIds.begin(), expectedIds.end(),
98 inputTensorIds.begin(), inputTensorIds.end());
103 TfLiteParser::ModelPtr model = TfLiteParser::LoadModelFromBinary(m_GraphBinary.data(), m_GraphBinary.size());
104 std::vector<int32_t> expectedIds = { };
105 std::vector<int32_t> outputTensorIds = TfLiteParser::GetOutputTensorIds(model, 0, 0);
106 BOOST_CHECK_EQUAL_COLLECTIONS(expectedIds.begin(), expectedIds.end(),
107 outputTensorIds.begin(), outputTensorIds.end());
112 TfLiteParser::ModelPtr model = TfLiteParser::LoadModelFromBinary(m_GraphBinary.data(), m_GraphBinary.size());
113 std::vector<int32_t> expectedInputIds = { 0, 1, 2 };
114 std::vector<int32_t> inputTensorIds = TfLiteParser::GetInputTensorIds(model, 0, 0);
115 BOOST_CHECK_EQUAL_COLLECTIONS(expectedInputIds.begin(), expectedInputIds.end(),
116 inputTensorIds.begin(), inputTensorIds.end());
121 TfLiteParser::ModelPtr model = TfLiteParser::LoadModelFromBinary(m_GraphBinary.data(), m_GraphBinary.size());
122 std::vector<int32_t> expectedOutputIds = { 3 };
123 std::vector<int32_t> outputTensorIds = TfLiteParser::GetOutputTensorIds(model, 0, 0);
124 BOOST_CHECK_EQUAL_COLLECTIONS(expectedOutputIds.begin(), expectedOutputIds.end(),
125 outputTensorIds.begin(), outputTensorIds.end());
140 TfLiteParser::ModelPtr model = TfLiteParser::LoadModelFromBinary(m_GraphBinary.data(), m_GraphBinary.size());
146 TfLiteParser::ModelPtr model = TfLiteParser::LoadModelFromBinary(m_GraphBinary.data(), m_GraphBinary.size());
152 TfLiteParser::ModelPtr model = TfLiteParser::LoadModelFromBinary(m_GraphBinary.data(), m_GraphBinary.size());
158 TfLiteParser::ModelPtr model = TfLiteParser::LoadModelFromBinary(m_GraphBinary.data(), m_GraphBinary.size());
BOOST_AUTO_TEST_SUITE(TensorflowLiteParser)
BOOST_FIXTURE_TEST_CASE(GetEmptyInputTensorIds, GetEmptyTensorIdsFixture)
bool ReadStringToBinary()
TfLiteParser::ModelPtr ModelPtr
BOOST_AUTO_TEST_SUITE_END()