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

Function LoadGraph

examples/tensorflow_wrapper/label_image/label_image.cpp:109–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

107}
108
109static TF_Session* LoadGraph(const char* model_file, TF_Graph* graph)
110{
111 TF_Status* s = TF_NewStatus();
112
113 vector<char> model_buf;
114
115 if(ReadEntireFile(model_file, model_buf) < 0)
116 return nullptr;
117
118 TF_Buffer graph_def = {model_buf.data(), model_buf.size(), nullptr};
119
120 TF_ImportGraphDefOptions* import_opts = TF_NewImportGraphDefOptions();
121 TF_ImportGraphDefOptionsSetPrefix(import_opts, "");
122 TF_GraphImportGraphDef(graph, &graph_def, import_opts, s);
123
124 if(TF_GetCode(s) != TF_OK)
125 {
126 printf("load graph failed!\n Error: %s\n", TF_Message(s));
127 return nullptr;
128 }
129
130 TF_SessionOptions* sess_opts = TF_NewSessionOptions();
131 TF_Session* session = TF_NewSession(graph, sess_opts, s);
132 assert(TF_GetCode(s) == TF_OK);
133
134 TF_DeleteStatus(s);
135
136 return session;
137}
138
139static int PrintTopLabels(const vector<TF_Tensor*>& outputs, const char* labels_file)
140{

Callers 7

LoadModelFromMemMethod · 0.85
LoadModelFromMemMethod · 0.85
mainFunction · 0.85
LoadModelMethod · 0.85
LoadModelMethod · 0.85
LoadModelMethod · 0.85
LoadModelMethod · 0.85

Calls 3

ReadEntireFileFunction · 0.85
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected