| 35 | namespace TEngine { |
| 36 | |
| 37 | bool GraphExecutor::CreateGraph(void* exec_context, const char* graph_name, const char* model_name) |
| 38 | { |
| 39 | StaticGraphPtr static_graph; |
| 40 | Graph* graph = nullptr; |
| 41 | |
| 42 | /* create empty graph */ |
| 43 | if(model_name == nullptr) |
| 44 | { |
| 45 | graph = new Graph(graph_name); |
| 46 | graph->SetModelFormat(MODEL_FORMAT_TENGINE); |
| 47 | graph->SetLayout(TENGINE_LAYOUT_NCHW); |
| 48 | graph->SetModelLayout(TENGINE_LAYOUT_NCHW); |
| 49 | } |
| 50 | else |
| 51 | { |
| 52 | if(!StaticGraphManager::SafeGet(model_name, static_graph)) |
| 53 | { |
| 54 | set_tengine_errno(ENOENT); |
| 55 | return false; |
| 56 | } |
| 57 | |
| 58 | graph = Graph::CreateFromStatic(graph_name, static_graph); |
| 59 | |
| 60 | if(graph == nullptr) |
| 61 | return false; |
| 62 | |
| 63 | model_name_ = model_name; |
| 64 | } |
| 65 | |
| 66 | graph_ = graph; |
| 67 | |
| 68 | return PrepareExec(exec_context, graph_, static_graph.get()); |
| 69 | } |
| 70 | |
| 71 | bool GraphExecutor::PrepareExec(void* exec_context, Graph* graph, StaticGraph* static_graph) |
| 72 | { |