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

Method LoadModelFromMem

serializer/tengine/v1/tm1_serializer.cpp:541–573  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

539}
540
541bool TmSerializer1::LoadModelFromMem(void* mmap_buf, StaticGraph* graph)
542{
543 const TM_Header* tm_header = reinterpret_cast<const TM_Header*>(mmap_buf);
544 /* Check the version of tm file format */
545 if(tm_header->ver_main != TM_FILE_VER_MAIN || tm_header->ver_sub != TM_FILE_VER_SUB ||
546 tm_header->ver_compile != TM_FILE_VER_COMPILE)
547 {
548 LOG_ERROR() << "Wrong version of tm file\n";
549 return false;
550 }
551
552 const TM_Model* tm_model = GetTmPtr<TM_Model>(mmap_buf, tm_header->offset_root);
553 if(tm_model->offset_s_mname == NOT_SET)
554 {
555 SetGraphIdentity(graph, "tengine", "tengine_model", "0");
556 }
557 else
558 {
559 std::string tm_model_name;
560 const TM_String* tm_string = GetTmPtr<TM_String>(mmap_buf, tm_model->offset_s_mname);
561 tm_model_name.assign(GetTmPtr<char>(mmap_buf, tm_string->offset_data), tm_string->size);
562 SetGraphIdentity(graph, "tengine", tm_model_name, "0");
563 }
564
565 SetModelFormat(graph, MODEL_FORMAT_TENGINE);
566 SetGraphLayout(graph, TENGINE_LAYOUT_NCHW);
567 SetModelLayout(graph, TENGINE_LAYOUT_NCHW);
568
569 if(LoadGraph(graph, tm_model, mmap_buf))
570 return true;
571 else
572 return false;
573}
574
575bool TmSerializerRegisterOpLoader1(void)
576{

Callers

nothing calls this directly

Calls 5

SetGraphIdentityFunction · 0.85
SetModelFormatFunction · 0.85
SetGraphLayoutFunction · 0.85
SetModelLayoutFunction · 0.85
LoadGraphFunction · 0.85

Tested by

no test coverage detected