MCPcopy Create free account
hub / github.com/OAID/Tengine / LoadModel

Method LoadModel

tengine-module/plugin/serializer/tf_lite/tf_lite_serializer.cpp:45–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43using op_load_t = std::function<bool(LiteNode* node, LiteGraph* lite_graph, StaticGraph* graph)>;
44
45bool TFLiteSerializer::LoadModel(const std::vector<std::string>& file_list, StaticGraph* graph)
46{
47 if(file_list.size() != GetFileNum())
48 return false;
49
50 std::ifstream input_file;
51
52 input_file.open(file_list[0], std::ios::binary | std::ios::in);
53 input_file.seekg(0, std::ios::end);
54
55 int model_len = input_file.tellg();
56 char* model_data = new char[model_len];
57
58 input_file.seekg(0, std::ios::beg);
59 input_file.read(model_data, model_len);
60 input_file.close();
61
62 SetGraphSource(graph, file_list[0]);
63 SetGraphSourceFormat(graph, "tflite");
64 SetGraphLayout(graph, TENGINE_LAYOUT_NHWC);
65 SetModelLayout(graph, TENGINE_LAYOUT_NHWC);
66 SetModelFormat(graph, MODEL_FORMAT_TFLITE);
67
68 bool ret = LoadModelFromMem(model_data, model_len, graph);
69
70 if(!ret)
71 delete[] model_data;
72
73 return ret;
74}
75
76bool TFLiteSerializer::LoadModelFromMem(char* mem_addr, int mem_size, StaticGraph* graph)
77{

Callers

nothing calls this directly

Calls 6

SetGraphSourceFunction · 0.85
SetGraphSourceFormatFunction · 0.85
SetGraphLayoutFunction · 0.85
SetModelLayoutFunction · 0.85
SetModelFormatFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected