From 709255d3987aa2e0ee1e4517f3ea1cb97bf62cf4 Mon Sep 17 00:00:00 2001 From: dongduo Date: Tue, 10 Nov 2020 14:22:44 +0800 Subject: [PATCH 1/6] Fix aclInferShapeAndType --- graphengine | 1 + 1 file changed, 1 insertion(+) create mode 160000 graphengine diff --git a/graphengine b/graphengine new file mode 160000 index 00000000..cd365aa2 --- /dev/null +++ b/graphengine @@ -0,0 +1 @@ +Subproject commit cd365aa247c64e30487d1e71e4f724a889848f80 From e1bd856bc16f2164943c32f88d524c07302b0458 Mon Sep 17 00:00:00 2001 From: dongduo Date: Tue, 10 Nov 2020 14:33:45 +0800 Subject: [PATCH 2/6] Fix aclInferShapeAndType --- ge/ir_build/ge_ir_build.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ge/ir_build/ge_ir_build.cc b/ge/ir_build/ge_ir_build.cc index b845bd75..7ae36777 100644 --- a/ge/ir_build/ge_ir_build.cc +++ b/ge/ir_build/ge_ir_build.cc @@ -439,6 +439,10 @@ graphStatus aclgrphGetIRVersion(int *major_version, int *minor_version, int *pat } graphStatus aclgrphInferShapeAndType(ge::Graph &graph) { + Impl builder; + std::map options = {}; + builder.Init(options); + auto compute_graph = GraphUtils::GetComputeGraph(graph); GE_CHECK_NOTNULL(compute_graph); From a96c8a74699bc6611ac1d02e4c092bddbbd74be7 Mon Sep 17 00:00:00 2001 From: dongduo Date: Tue, 17 Nov 2020 09:12:27 +0800 Subject: [PATCH 3/6] Fix aclgrphInferShapeAndType --- ge/ir_build/ge_ir_build.cc | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/ge/ir_build/ge_ir_build.cc b/ge/ir_build/ge_ir_build.cc index 7ae36777..f681cb78 100644 --- a/ge/ir_build/ge_ir_build.cc +++ b/ge/ir_build/ge_ir_build.cc @@ -35,6 +35,7 @@ #include "ir_build/atc_ir_common.h" #include "model/ge_model.h" #include "graph/shape_refiner.h" +#include "graph/opsproto_manager.h" using std::string; using namespace std; @@ -109,6 +110,27 @@ static graphStatus CheckGlobalOptions(std::map &global return GRAPH_SUCCESS; } +static void GetOpsProtoPath(string &opsproto_path) { + GELOGI("Start to get ops proto path schedule."); + 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, "File path %s is invalid.", path.c_str()); + return; + } + opsproto_path = (path + "/op_proto/custom/" + ":") + (path + "/op_proto/built-in/"); + GELOGI("Get opsproto so path from env : %s", path.c_str()); + return; + } + 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/"); +} + graphStatus aclgrphBuildInitialize(std::map global_options) { GELOGD("Enter aclgrphInitialize start!"); // check global options @@ -172,6 +194,7 @@ class Impl { bool is_dynamic_input); void SetRtSocVersion(); void UpdateThreadContext(); + void LoadOpsProto();s public: ge::GeGenerator generator_; std::map options_; @@ -313,6 +336,16 @@ void Impl::UpdateThreadContext() { GetThreadLocalContext().SetGraphOption(options_); } +void Impl::LoadOpsProto() { + string opsproto_path; + GetOpsProtoPath(opsproto_path); + 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); +} + graphStatus Impl::CreateInputsForIRBuild(const ge::Graph &graph, vector &inputs) { auto compute_graph = ge::GraphUtils::GetComputeGraph(graph); GE_CHECK_NOTNULL(compute_graph); @@ -440,12 +473,17 @@ graphStatus aclgrphGetIRVersion(int *major_version, int *minor_version, int *pat graphStatus aclgrphInferShapeAndType(ge::Graph &graph) { Impl builder; - std::map options = {}; - builder.Init(options); + builder.LoadOpsProto(); auto compute_graph = GraphUtils::GetComputeGraph(graph); GE_CHECK_NOTNULL(compute_graph); + auto root_graph = compute_graph->GetParentGraph(); + if (root_graph != nullptr) { + GELOGE(GRAPH_PARAM_INVALID, "Input param should not be subgraph"); + return GRAPH_PARAM_INVALID; + } + auto ret = compute_graph->InferOriginFormat(); if (ret != GRAPH_SUCCESS) { GELOGE(ret, "Acl InferOriginFormat failed."); From 1a67e74f70f6d797dd86e295641958bd40f3924f Mon Sep 17 00:00:00 2001 From: dongduo Date: Tue, 17 Nov 2020 09:24:37 +0800 Subject: [PATCH 4/6] Fix aclgrphInferShapeAndType --- ge/ir_build/ge_ir_build.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ge/ir_build/ge_ir_build.cc b/ge/ir_build/ge_ir_build.cc index f681cb78..3ff06d7a 100644 --- a/ge/ir_build/ge_ir_build.cc +++ b/ge/ir_build/ge_ir_build.cc @@ -138,9 +138,13 @@ graphStatus aclgrphBuildInitialize(std::map global_opt GELOGE(GRAPH_PARAM_INVALID, "Check global options falied!"); return GRAPH_PARAM_INVALID; } + // print global option map ge::PrintOptionMap(global_options, "global option"); + Impl builder; + builder.LoadOpsProto(); + std::shared_ptr instance_ptr = ge::GELib::GetInstance(); if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { GELOGI("aclgrphInitialize start!"); @@ -472,9 +476,6 @@ graphStatus aclgrphGetIRVersion(int *major_version, int *minor_version, int *pat } graphStatus aclgrphInferShapeAndType(ge::Graph &graph) { - Impl builder; - builder.LoadOpsProto(); - auto compute_graph = GraphUtils::GetComputeGraph(graph); GE_CHECK_NOTNULL(compute_graph); From 5044e1f1330cb777c53dec412606db728376d5ef Mon Sep 17 00:00:00 2001 From: dongduo Date: Tue, 17 Nov 2020 10:27:34 +0800 Subject: [PATCH 5/6] Fix aclgrphInferShapeAndType --- graphengine | 1 - 1 file changed, 1 deletion(-) delete mode 160000 graphengine diff --git a/graphengine b/graphengine deleted file mode 160000 index cd365aa2..00000000 --- a/graphengine +++ /dev/null @@ -1 +0,0 @@ -Subproject commit cd365aa247c64e30487d1e71e4f724a889848f80 From 7ec5ab95efc745742a6ac78230418c4aec2474fb Mon Sep 17 00:00:00 2001 From: dongduo Date: Tue, 17 Nov 2020 10:41:47 +0800 Subject: [PATCH 6/6] Fix aclgrphInferShapeAndType --- ge/ir_build/ge_ir_build.cc | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/ge/ir_build/ge_ir_build.cc b/ge/ir_build/ge_ir_build.cc index 3ff06d7a..ccf3b24e 100644 --- a/ge/ir_build/ge_ir_build.cc +++ b/ge/ir_build/ge_ir_build.cc @@ -131,6 +131,16 @@ static void GetOpsProtoPath(string &opsproto_path) { opsproto_path = (path_base + "ops/op_proto/custom/" + ":") + (path_base + "ops/op_proto/built-in/"); } +static void LoadOpsProto() { + string opsproto_path; + GetOpsProtoPath(opsproto_path); + 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); +} + graphStatus aclgrphBuildInitialize(std::map global_options) { GELOGD("Enter aclgrphInitialize start!"); // check global options @@ -142,8 +152,7 @@ graphStatus aclgrphBuildInitialize(std::map global_opt // print global option map ge::PrintOptionMap(global_options, "global option"); - Impl builder; - builder.LoadOpsProto(); + LoadOpsProto(); std::shared_ptr instance_ptr = ge::GELib::GetInstance(); if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { @@ -198,7 +207,7 @@ class Impl { bool is_dynamic_input); void SetRtSocVersion(); void UpdateThreadContext(); - void LoadOpsProto();s + void LoadOpsProto(); public: ge::GeGenerator generator_; std::map options_; @@ -340,16 +349,6 @@ void Impl::UpdateThreadContext() { GetThreadLocalContext().SetGraphOption(options_); } -void Impl::LoadOpsProto() { - string opsproto_path; - GetOpsProtoPath(opsproto_path); - 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); -} - graphStatus Impl::CreateInputsForIRBuild(const ge::Graph &graph, vector &inputs) { auto compute_graph = ge::GraphUtils::GetComputeGraph(graph); GE_CHECK_NOTNULL(compute_graph);