MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / Import

Function Import

tensorflow/lite/toco/tflite/import.cc:201–235  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

199} // namespace
200
201std::unique_ptr<Model> Import(const ModelFlags& model_flags,
202 const string& input_file_contents) {
203 ::tflite::AlwaysTrueResolver r;
204 if (!::tflite::Verify(input_file_contents.data(), input_file_contents.size(),
205 r, ::tflite::DefaultErrorReporter())) {
206 LOG(FATAL) << "Invalid flatbuffer.";
207 }
208 const ::tflite::Model* input_model =
209 ::tflite::GetModel(input_file_contents.data());
210
211 // Full list of all known operators.
212 const auto ops_by_name = BuildOperatorByNameMap();
213
214 if (!input_model->subgraphs() || input_model->subgraphs()->size() != 1) {
215 LOG(FATAL) << "Number of subgraphs in tflite should be exactly 1.";
216 }
217 std::unique_ptr<Model> model;
218 model.reset(new Model);
219
220 details::TensorsTable tensors_table;
221 details::LoadTensorsTable(*input_model, &tensors_table);
222
223 details::OperatorsTable operators_table;
224 details::LoadOperatorsTable(*input_model, &operators_table);
225
226 ImportTensors(*input_model, model.get());
227 ImportOperators(*input_model, ops_by_name, tensors_table, operators_table,
228 model.get());
229
230 ImportIOTensors(model_flags, *input_model, tensors_table, model.get());
231
232 UndoWeightsShuffling(model.get());
233
234 return model;
235}
236
237} // namespace tflite
238

Callers 2

TEST_FFunction · 0.70
TocoConvertFunction · 0.50

Calls 14

DefaultErrorReporterFunction · 0.85
GetModelFunction · 0.85
BuildOperatorByNameMapFunction · 0.85
LoadTensorsTableFunction · 0.85
LoadOperatorsTableFunction · 0.85
ImportTensorsFunction · 0.85
ImportOperatorsFunction · 0.85
ImportIOTensorsFunction · 0.85
UndoWeightsShufflingFunction · 0.85
VerifyFunction · 0.70
dataMethod · 0.45
sizeMethod · 0.45

Tested by 1

TEST_FFunction · 0.56