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

Method LoadNode

serializer/tengine/v2/tm2_serializer.cpp:467–529  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

465}
466
467bool TmSerializer2::LoadNode(StaticGraph* graph, StaticNode* node, const TM2_Node* tm_node, void* mmap_buf)
468{
469 if(tm_node->offset_vi_input_tensors != TM2_NOT_SET)
470 {
471 const TM2_Vector_indices* v_input_tensors =
472 GetTmPtr<TM2_Vector_indices>(mmap_buf, tm_node->offset_vi_input_tensors);
473
474 /* Set the input tensors to the node */
475 for(unsigned int i = 0; i < v_input_tensors->v_num; i++)
476 {
477 StaticTensor* tensor = graph->tensor_list[v_input_tensors->indices[i]].get();
478 if(!tensor)
479 {
480 LOG_ERROR() << "The input tensor not exist: " << v_input_tensors->indices[i] << "\n";
481 return false;
482 }
483 AddNodeInputTensor(node, tensor);
484 }
485 }
486
487 if(tm_node->offset_vi_output_tensors != TM2_NOT_SET)
488 {
489 const TM2_Vector_indices* v_output_tensors =
490 GetTmPtr<TM2_Vector_indices>(mmap_buf, tm_node->offset_vi_output_tensors);
491
492 /* Set the output tensors to the node */
493 for(unsigned int i = 0; i < v_output_tensors->v_num; i++)
494 {
495 StaticTensor* tensor = graph->tensor_list[v_output_tensors->indices[i]].get();
496 if(!tensor)
497 {
498 LOG_ERROR() << "The output tensor not exist: " << v_output_tensors->indices[i] << "\n";
499 return false;
500 }
501 AddNodeOutputTensor(node, tensor);
502 }
503 }
504
505 /* set the custom attributes into static node */
506 if(tm_node->offset_vo_attrs == TM2_NOT_SET)
507 return true;
508
509 const TM2_Vector_offsets* v_attrs = GetTmPtr<TM2_Vector_offsets>(mmap_buf, tm_node->offset_vo_attrs);
510 for(unsigned int i = 0; i < v_attrs->v_num; i++)
511 {
512 const TM2_Attr* tm_attr = GetTmPtr<TM2_Attr>(mmap_buf, v_attrs->offsets[i]);
513 const TM2_String* tm_attr_name = GetTmPtr<TM2_String>(mmap_buf, tm_attr->offset_s_attrname);
514 const TM2_String* tm_attr_val = GetTmPtr<TM2_String>(mmap_buf, tm_attr->offset_s_attrval);
515
516 const char* attr_name = GetTmPtr<char>(mmap_buf, tm_attr_name->offset_data);
517 const char* attr_val = GetTmPtr<char>(mmap_buf, tm_attr_val->offset_data);
518 const char* type_name = int_to_typename(tm_attr->attr_type);
519
520 if(NodeAddParamGeneric(node, attr_name, type_name, tm_attr_val->size) < 0 ||
521 NodeSetParamGeneric(node, attr_name, type_name, attr_val, tm_attr_val->size) < 0)
522 {
523 LOG_ERROR() << "Add and set node param failed\n";
524 return false;

Callers

nothing calls this directly

Calls 6

AddNodeInputTensorFunction · 0.85
AddNodeOutputTensorFunction · 0.85
int_to_typenameFunction · 0.85
NodeAddParamGenericFunction · 0.85
NodeSetParamGenericFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected