| @@ -87,12 +87,13 @@ Status ModelHelper::SaveSizeToModelDef(const GeModelPtr &ge_model) { | |||
| std::shared_ptr<ModelTaskDef> 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."); | |||
| @@ -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<uint64_t> 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<string, string> option_tmp; | |||
| option_tmp.emplace(std::pair<string, string>(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 init_hostcpu_engine_status = HostCpuEngine::GetInstance().Initialize(); | |||
| if (init_hostcpu_engine_status != SUCCESS) { | |||
| GELOGE(init_hostcpu_engine_status, "Failed to initialize HostCpuEngine"); | |||
| return init_hostcpu_engine_status; | |||
| } | |||
| InitOpsProtoManager(); | |||
| std::vector<rtMemType_t> mem_type(1, RT_MEMORY_HBM); | |||
| mem_type.push_back(RT_MEMORY_P2P_DDR); | |||
| auto ret = MemManager::Instance().Initialize(mem_type); | |||
| @@ -565,6 +565,44 @@ bool GeGenerator::Impl::SetOmSystemInfo(AttrHolder &obj) { | |||
| return true; | |||
| } | |||
| Status GeGenerator::SetModelNameForDump(const 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 = MakeShared<GeModel>(); | |||
| 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<string, GeModelPtr> 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<GeTensor> &inputs, | |||
| ModelBufferData &model, bool is_offline) { | |||
| rtContext_t ctx = nullptr; | |||
| @@ -599,20 +637,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<string, GeModelPtr> 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"); | |||
| @@ -882,13 +910,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<GeModel>(); | |||
| 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!"); | |||
| @@ -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(); | |||
| @@ -149,14 +149,16 @@ Status NodeItem::InitInputsAndOutputs() { | |||
| if (AttrUtils::GetInt(op_desc, ::ge::ATTR_STAGE_LEVEL, group)) { | |||
| GELOGD("[%s] Got stage level from op_desc = %d", op_desc->GetName().c_str(), group); | |||
| } else { | |||
| if (AttrUtils::GetInt(node->GetOwnerComputeGraph(), ::ge::ATTR_STAGE_LEVEL, group)) { | |||
| GELOGD("[%s] Got stage level from parent graph = %d", op_desc->GetName().c_str(), group); | |||
| } else { | |||
| auto parent_node = node->GetOwnerComputeGraph()->GetParentNode(); | |||
| if ((parent_node != nullptr) && (AttrUtils::GetInt(parent_node->GetOpDesc(), ::ge::ATTR_STAGE_LEVEL, group))) { | |||
| GELOGD("[%s] Got stage level from parent node = %d", op_desc->GetName().c_str(), group); | |||
| if (node->GetOwnerComputeGraph() != nullptr) { | |||
| if (AttrUtils::GetInt(node->GetOwnerComputeGraph(), ::ge::ATTR_STAGE_LEVEL, group)) { | |||
| GELOGD("[%s] Got stage level from parent graph = %d", op_desc->GetName().c_str(), group); | |||
| } else { | |||
| GELOGD("[%s] Node do not set stage level", op_desc->GetName().c_str()); | |||
| auto parent_node = node->GetOwnerComputeGraph()->GetParentNode(); | |||
| if ((parent_node != nullptr) && (AttrUtils::GetInt(parent_node->GetOpDesc(), ::ge::ATTR_STAGE_LEVEL, group))) { | |||
| GELOGD("[%s] Got stage level from parent node = %d", op_desc->GetName().c_str(), group); | |||
| } else { | |||
| GELOGD("[%s] Node do not set stage level", op_desc->GetName().c_str()); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -29,6 +29,7 @@ | |||
| #include "graph/op_desc.h" | |||
| #include "graph/detail/attributes_holder.h" | |||
| #include "omg/omg_inner_types.h" | |||
| #include "model/ge_root_model.h" | |||
| namespace ge { | |||
| class GE_FUNC_VISIBILITY GeGenerator { | |||
| @@ -98,6 +99,7 @@ class GE_FUNC_VISIBILITY GeGenerator { | |||
| const string &model_file_name, OpEngineType engine_type, ModelBufferData &model_buff, | |||
| bool is_offline = true); | |||
| Status CheckForSingleOp(OpDescPtr &op_desc, const vector<GeTensor> &inputs, const vector<GeTensor> &outputs); | |||
| Status SetModelNameForDump(const GeRootModelPtr &ge_root_model); | |||
| class Impl; | |||
| @@ -39,4 +39,10 @@ TEST_F(UtestGeExecutor, test_single_op_exec) { | |||
| EXPECT_EQ(exeutor.LoadSingleOp(model_name, model_data, nullptr, nullptr), ACL_ERROR_GE_INTERNAL_ERROR); | |||
| EXPECT_EQ(exeutor.LoadDynamicSingleOp(model_name, model_data, nullptr, nullptr), PARAM_INVALID); | |||
| } | |||
| TEST_F(UtestGeExecutor, test_ge_initialize) { | |||
| GeExecutor executor; | |||
| EXPECT_EQ(executor.Initialize(), SUCCESS); | |||
| EXPECT_EQ(executor.Initialize(), SUCCESS); | |||
| } | |||
| } // namespace ge | |||
| @@ -25,6 +25,7 @@ | |||
| #include "graph/utils/graph_utils.h" | |||
| #include "../graph/passes/graph_builder_utils.h" | |||
| #include "../graph/manager/graph_manager.h" | |||
| #include "all_ops.h" | |||
| using namespace std; | |||
| @@ -110,4 +111,14 @@ TEST_F(UtestGeGenerator, test_graph_manager) { | |||
| graph_partitioner.graph_2_subgraph_list_.insert({sub_graph, {sgi, sgi_gelocal}}); | |||
| EXPECT_EQ(graph_manager.ConvertGraphToFile(root_graph, graph_partitioner, "./"), GRAPH_SUCCESS); | |||
| } | |||
| TEST_F(UtestGeGenerator, test_set_model_name) { | |||
| GeGenerator generator; | |||
| generator.Initialize({}); | |||
| GeRootModelPtr ge_root_model = make_shared<GeRootModel>(GeRootModel()); | |||
| ComputeGraphPtr graph = make_shared<ComputeGraph>(ComputeGraph("graph")); | |||
| (void)AttrUtils::SetBool(graph, "_dynamic_shape_partitioned", true); | |||
| ge_root_model->root_graph_ = std::move(graph); | |||
| EXPECT_EQ(generator.SetModelNameForDump(ge_root_model), SUCCESS); | |||
| } | |||
| } // namespace ge | |||
| @@ -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<ge::GeModel>(); | |||
| 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<ge::GeModel>(); | |||