diff --git a/ge/common/helper/model_helper.cc b/ge/common/helper/model_helper.cc index 82449ff3..02c0a8f0 100644 --- a/ge/common/helper/model_helper.cc +++ b/ge/common/helper/model_helper.cc @@ -891,6 +891,7 @@ Status ModelTool::GetModelInfoFromOm(const char *model_file, ge::proto::ModelDef model.model_data = nullptr; } }; + GE_MAKE_GUARD(release, callback); uint8_t *model_data = nullptr; uint32_t model_len = 0; @@ -903,17 +904,17 @@ Status ModelTool::GetModelInfoFromOm(const char *model_file, ge::proto::ModelDef return ret; } - OmFileLoadHelper omFileLoadHelper; - ret = omFileLoadHelper.Init(model_data, model_len); - if (ret != ge::GRAPH_SUCCESS) { + OmFileLoadHelper om_load_helper; + ret = om_load_helper.Init(model_data, model_len); + if (ret != SUCCESS) { ErrorManager::GetInstance().ATCReportErrMessage("E19021", {"reason"}, {"Om file init failed"}); GELOGE(ge::FAILED, "Om file init failed."); return ret; } ModelPartition ir_part; - ret = omFileLoadHelper.GetModelPartition(MODEL_DEF, ir_part); - if (ret != ge::GRAPH_SUCCESS) { + ret = om_load_helper.GetModelPartition(MODEL_DEF, ir_part); + if (ret != SUCCESS) { ErrorManager::GetInstance().ATCReportErrMessage("E19021", {"reason"}, {"Get model part failed"}); GELOGE(ge::FAILED, "Get model part failed."); return ret; diff --git a/ge/init/gelib.cc b/ge/init/gelib.cc index a0014018..19085c19 100644 --- a/ge/init/gelib.cc +++ b/ge/init/gelib.cc @@ -543,7 +543,10 @@ Status GEInit::Initialize(const map &options) { } Status GEInit::Finalize() { - return GELib::GetInstance()->Finalize(); + std::shared_ptr instance_ptr = ge::GELib::GetInstance(); + if (instance_ptr != nullptr) { + return instance_ptr->Finalize(); + } } string GEInit::GetPath() { diff --git a/tests/ut/ge/graph/load/model_helper_unittest.cc b/tests/ut/ge/graph/load/model_helper_unittest.cc index 455285bf..5eacd9eb 100644 --- a/tests/ut/ge/graph/load/model_helper_unittest.cc +++ b/tests/ut/ge/graph/load/model_helper_unittest.cc @@ -49,4 +49,21 @@ TEST_F(UtestModelHelper, save_size_to_modeldef) ModelHelper model_helper; EXPECT_EQ(SUCCESS, model_helper.SaveSizeToModelDef(ge_model)); } + +TEST_F(UtestModelHelper, atc_test) +{ + ge::proto::ModelDef model_def; + uint32_t modeldef_size = 0; + + GEInit::Finalize(); + char buffer[1024]; + getcwd(buffer, 1024); + string path=buffer; + string file_path=path + "/Makefile"; + + ModelTool::GetModelInfoFromOm(file_path.c_str(), model_def, modeldef_size); + ModelTool::GetModelInfoFromOm("123.om", model_def, modeldef_size); + ModelTool::GetModelInfoFromPbtxt(file_path.c_str(), model_def); + ModelTool::GetModelInfoFromPbtxt("123.pbtxt", model_def); +} } // namespace ge