diff --git a/ge/common/helper/model_helper.cc b/ge/common/helper/model_helper.cc index 02c0a8f0..74238bc1 100644 --- a/ge/common/helper/model_helper.cc +++ b/ge/common/helper/model_helper.cc @@ -87,12 +87,13 @@ Status ModelHelper::SaveSizeToModelDef(const GeModelPtr &ge_model) { std::shared_ptr model_task_def = ge_model->GetModelTaskDefPtr(); if (model_task_def == nullptr) { - GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "Create model task def ptr failed"); - return ACL_ERROR_GE_MEMORY_ALLOCATION; + GELOGD("SaveSizeToModelDef task_info_size is 0."); + om_info.push_back(0); + } else { + size_t partition_task_size = model_task_def->ByteSizeLong(); + GELOGD("SaveSizeToModelDef task_info_size is %zu", partition_task_size); + om_info.push_back(partition_task_size); } - size_t partition_task_size = model_task_def->ByteSizeLong(); - GELOGD("SaveSizeToModelDef task_info_size is %zu", partition_task_size); - om_info.push_back(partition_task_size); GE_CHK_BOOL_EXEC(ge::AttrUtils::SetListInt(*(ge_model.get()), "om_info_list", om_info), GELOGE(FAILED, "SetListInt of om_info_list failed."); diff --git a/ge/executor/ge_executor.cc b/ge/executor/ge_executor.cc index 44b2dbfa..c69a9d1e 100755 --- a/ge/executor/ge_executor.cc +++ b/ge/executor/ge_executor.cc @@ -30,6 +30,8 @@ #include "single_op/single_op_manager.h" #include "graph/load/model_manager/davinci_model.h" #include "opskernel_manager/ops_kernel_builder_manager.h" +#include "graph/opsproto_manager.h" +#include "ge_local_engine/engine/host_cpu_engine.h" using std::string; using std::vector; @@ -199,6 +201,33 @@ bool IsDynmaicDimsSizeMatchModel(const vector cur_dynamic_dims, namespace ge { bool GeExecutor::isInit_ = false; +static void InitOpsProtoManager() { + string opsproto_path; + const char *path_env = std::getenv("ASCEND_OPP_PATH"); + if (path_env != nullptr) { + string path = path_env; + string file_path = RealPath(path.c_str()); + if (file_path.empty()) { + GELOGE(FAILED, "[Check][EnvPath]ASCEND_OPP_PATH path [%s] is invalid.", path.c_str()); + REPORT_INPUT_ERROR("E68016", {"ASCEND_OPP_PATH", path}); + return; + } + opsproto_path = (path + "/op_proto/custom/" + ":") + (path + "/op_proto/built-in/"); + GELOGI("Get opsproto so path from env : %s", path.c_str()); + } else { + string path_base = PluginManager::GetPath(); + GELOGI("path_base is %s", path_base.c_str()); + path_base = path_base.substr(0, path_base.rfind('/')); + path_base = path_base.substr(0, path_base.rfind('/') + 1); + opsproto_path = (path_base + "ops/op_proto/custom/" + ":") + (path_base + "ops/op_proto/built-in/"); + } + GELOGI("Get opsproto path is %s", opsproto_path.c_str()); + OpsProtoManager *manager = OpsProtoManager::Instance(); + map option_tmp; + option_tmp.emplace(std::pair(string("ge.opsProtoLibPath"), opsproto_path)); + (void)manager->Initialize(option_tmp); +} + GeExecutor::GeExecutor() {} Status GeExecutor::Initialize() { @@ -208,6 +237,16 @@ Status GeExecutor::Initialize() { return ge::SUCCESS; } + OpTilingManager::GetInstance().LoadSo(); + + Status initHostCpuEngineStatus = HostCpuEngine::GetInstance().Initialize(); + if (initHostCpuEngineStatus != SUCCESS) { + GELOGE(initHostCpuEngineStatus, "Failed to initialize HostCpuEngine"); + return initHostCpuEngineStatus; + } + + InitOpsProtoManager(); + std::vector mem_type(1, RT_MEMORY_HBM); mem_type.push_back(RT_MEMORY_P2P_DDR); auto ret = MemManager::Instance().Initialize(mem_type); diff --git a/ge/generator/ge_generator.cc b/ge/generator/ge_generator.cc index 938a8bc6..3f934fdb 100644 --- a/ge/generator/ge_generator.cc +++ b/ge/generator/ge_generator.cc @@ -556,6 +556,44 @@ bool GeGenerator::Impl::SetOmSystemInfo(AttrHolder &obj) { return true; } +static Status SetModelNameForDump(GeRootModelPtr ge_root_model) { + bool is_unknown_shape = false; + Status ret = ge_root_model->CheckIsUnknownShape(is_unknown_shape); + if (ret != SUCCESS) { + GELOGE(FAILED, "[Check][IsUnknownShape]Check root model is unknown shape failed, model id:%u", + ge_root_model->GetModelId()); + REPORT_CALL_ERROR("E19999", "Check root model is unknown shape failed, model id:%zu", + ge_root_model->GetModelId()); + return FAILED; + } + GeModelPtr model_root = nullptr; + if (is_unknown_shape) { + model_root = make_shared(); + GE_CHECK_NOTNULL(model_root); + model_root->SetGraph(GraphUtils::CreateGraphFromComputeGraph(ge_root_model->GetRootGraph())); + ge_root_model->SetSubgraphInstanceNameToModel(ge_root_model->GetRootGraph()->GetName(), model_root); + } + + ModelHelper model_helper; + string model_name; + GE_CHECK_NOTNULL(ge_root_model->GetRootGraph()); + Status name_ret = model_helper.GetModelNameFromMergedGraphName(ge_root_model->GetRootGraph()->GetName(), + model_name); + if (name_ret != SUCCESS) { + ErrorManager::GetInstance().ATCReportErrMessage("E10000", {"parameter"}, {"output"}); + GELOGE(FAILED, "[Check][GetModelNameStep]Get model_name failed. Param --output is invalid, root graph name: %s", + ge_root_model->GetRootGraph()->GetName().c_str()); + REPORT_CALL_ERROR("E19999", "Get model_name failed. Param --output is invalid,", + "root graph name: %s", ge_root_model->GetRootGraph()->GetName().c_str()); + return PARAM_INVALID; + } + map name_to_ge_model = ge_root_model->GetSubgraphInstanceNameToModel(); + GeModelPtr &ge_model = name_to_ge_model[ge_root_model->GetRootGraph()->GetName()]; + GE_CHECK_NOTNULL(ge_model); + ge_model->SetName(model_name); + return SUCCESS; +} + Status GeGenerator::GenerateModel(const Graph &graph, const string &file_name_prefix, const vector &inputs, ModelBufferData &model, bool is_offline) { rtContext_t ctx = nullptr; @@ -590,20 +628,10 @@ Status GeGenerator::GenerateModel(const Graph &graph, const string &file_name_pr } GE_CHECK_NOTNULL(ge_root_model); - GE_CHECK_NOTNULL(ge_root_model->GetRootGraph()); - ModelHelper model_helper; - string model_name = ""; - Status name_ret = model_helper.GetModelNameFromMergedGraphName(ge_root_model->GetRootGraph()->GetName(), - model_name); - if (name_ret != SUCCESS) { - ErrorManager::GetInstance().ATCReportErrMessage("E10000", {"parameter"}, {"output"}); - GELOGE(FAILED, "Get model_name failed. Param --output is invalid."); - return PARAM_INVALID; + ret = SetModelNameForDump(ge_root_model); + if (ret != SUCCESS) { + return ret; } - map name_to_ge_model = ge_root_model->GetSubgraphInstanceNameToModel(); - GeModelPtr &ge_model = name_to_ge_model[ge_root_model->GetRootGraph()->GetName()]; - GE_RETURN_WITH_LOG_IF_FALSE(ge_model != nullptr, "ge_model cannot be null"); - ge_model->SetName(model_name); ret = impl_->SaveRootModel(file_name_prefix, ge_root_model, model); if (ret != SUCCESS) { GELOGE(ret, "Save model failed"); @@ -873,13 +901,12 @@ Status GeGenerator::Impl::SaveRootModel(const string &file_name_prefix, GeRootMo "ge root model has no sub model") GeModelPtr model_root = nullptr; if (is_unknown_shape) { - model_root = make_shared(); - model_root->SetGraph(GraphUtils::CreateGraphFromComputeGraph(ge_root_model->GetRootGraph())); - ge_root_model->SetSubgraphInstanceNameToModel(ge_root_model->GetRootGraph()->GetName(), model_root); - model_root->SetName(ge_root_model->GetRootGraph()->GetName()); + auto name_to_ge_model = ge_root_model->GetSubgraphInstanceNameToModel(); + model_root = name_to_ge_model[ge_root_model->GetRootGraph()->GetName()]; } else { model_root = ge_root_model->GetSubgraphInstanceNameToModel().begin()->second; } + GE_CHECK_NOTNULL(model_root); // set atc version if (!SetAtcVersionInfo(*(model_root.get()))) { GELOGW("SetPackageVersionInfo of atc failed!"); diff --git a/ge/graph/build/graph_builder.cc b/ge/graph/build/graph_builder.cc index 0883d895..791d301c 100644 --- a/ge/graph/build/graph_builder.cc +++ b/ge/graph/build/graph_builder.cc @@ -387,7 +387,7 @@ static Status InsertMemcpyNode(const ComputeGraphPtr &graph, const OutDataAnchor GE_CHECK_NOTNULL(out_anchor); NodePtr in_node = out_anchor->GetOwnerNode(); GE_CHECK_NOTNULL(in_node); - OpDescBuilder op_desc_builder(name, MEMCPYADDRASYNC); + OpDescBuilder op_desc_builder(name, MEMCPYASYNC); OpDescPtr op_desc = op_desc_builder.AddInput("x", in_node->GetOpDesc()->GetOutputDesc(0)) .AddOutput("y", in_node->GetOpDesc()->GetOutputDesc(0)) .Build(); diff --git a/tests/ut/ge/graph/load/model_helper_unittest.cc b/tests/ut/ge/graph/load/model_helper_unittest.cc index 03605dc7..8fd8f014 100644 --- a/tests/ut/ge/graph/load/model_helper_unittest.cc +++ b/tests/ut/ge/graph/load/model_helper_unittest.cc @@ -36,13 +36,6 @@ class UtestModelHelper : public testing::Test { void TearDown() override {} }; -TEST_F(UtestModelHelper, save_size_to_modeldef_failed) -{ - GeModelPtr ge_model = ge::MakeShared(); - ModelHelper model_helper; - EXPECT_EQ(ACL_ERROR_GE_MEMORY_ALLOCATION, model_helper.SaveSizeToModelDef(ge_model)); -} - TEST_F(UtestModelHelper, save_size_to_modeldef) { GeModelPtr ge_model = ge::MakeShared();