| 448 | } |
| 449 | |
| 450 | bool TmSerializer1::LoadGraph(StaticGraph* graph, const TM_Model* tm_model, void* mmap_buf) |
| 451 | { |
| 452 | const TM_Vector_offsets* v_graphs = GetTmPtr<TM_Vector_offsets>(mmap_buf, tm_model->offset_vo_subgraphs); |
| 453 | const TM_Subgraph* tm_graph = GetTmPtr<TM_Subgraph>(mmap_buf, v_graphs->offsets[0]); |
| 454 | |
| 455 | const TM_Vector_offsets* v_nodes = GetTmPtr<TM_Vector_offsets>(mmap_buf, tm_graph->offset_vo_seq_nodes); |
| 456 | const TM_Vector_offsets* v_tensors = GetTmPtr<TM_Vector_offsets>(mmap_buf, tm_graph->offset_vo_tensors); |
| 457 | const TM_Vector_offsets* v_buffers = GetTmPtr<TM_Vector_offsets>(mmap_buf, tm_graph->offset_vo_buffers); |
| 458 | |
| 459 | /* Load const tensors */ |
| 460 | for(unsigned int i = 0; i < v_tensors->v_num; i++) |
| 461 | { |
| 462 | const TM_Tensor* tm_tensor = GetTmPtr<TM_Tensor>(mmap_buf, v_tensors->offsets[i]); |
| 463 | const TM_Buffer* tm_buf; |
| 464 | if(tm_tensor->type == kConstTensor) |
| 465 | tm_buf = GetTmPtr<TM_Buffer>(mmap_buf, v_buffers->offsets[tm_tensor->buffer_id]); |
| 466 | else |
| 467 | tm_buf = nullptr; |
| 468 | LoadTensor(graph, tm_tensor, tm_buf, mmap_buf); |
| 469 | } |
| 470 | |
| 471 | /* Create static nodes */ |
| 472 | unsigned int i; |
| 473 | for(i = 0; i < v_nodes->v_num; i++) |
| 474 | { |
| 475 | const TM_Node* tm_node = GetTmPtr<TM_Node>(mmap_buf, v_nodes->offsets[i]); |
| 476 | int idx = tm_node->node_id; |
| 477 | std::string tm_node_name; |
| 478 | if(tm_node->offset_s_nname == NOT_SET) |
| 479 | tm_node_name = "node_" + std::to_string(idx); |
| 480 | else |
| 481 | { |
| 482 | const TM_String* tm_string = GetTmPtr<TM_String>(mmap_buf, tm_node->offset_s_nname); |
| 483 | tm_node_name.assign(GetTmPtr<char>(mmap_buf, tm_string->offset_data), tm_string->size); |
| 484 | } |
| 485 | |
| 486 | const TM_Operator* tm_operator = GetTmPtr<TM_Operator>(mmap_buf, tm_node->offset_t_operator); |
| 487 | const std::string& tm_op_name = GetOpStr(tm_operator->operator_type); |
| 488 | |
| 489 | if(!FindOpLoadMethod(tm_op_name)) |
| 490 | { |
| 491 | LOG_ERROR() << "cannot find load function for operator: " << tm_op_name << "\n"; |
| 492 | break; |
| 493 | } |
| 494 | |
| 495 | StaticNode* node = CreateStaticNode(graph, tm_node_name); |
| 496 | if(!LoadNode(graph, node, tm_node, mmap_buf)) |
| 497 | break; |
| 498 | |
| 499 | op_load_t op_func = any_cast<op_load_t>(GetOpLoadMethod(tm_op_name)); |
| 500 | |
| 501 | if(!op_func(graph, node, mmap_buf, tm_operator)) |
| 502 | break; |
| 503 | |
| 504 | /* Set the dynamic shape of the operator */ |
| 505 | node->op->dynamic_shape = tm_node->dynamic_shape; |
| 506 | } |
| 507 |
nothing calls this directly
no test coverage detected