From f8fdd9bd4dc24eeca4ba26d1746869572f50edfb Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 3 Feb 2021 20:53:37 +0800 Subject: [PATCH 1/3] Check dynamic support. --- ge/generator/ge_generator.cc | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/ge/generator/ge_generator.cc b/ge/generator/ge_generator.cc index 90b7f776..9d9fc23c 100644 --- a/ge/generator/ge_generator.cc +++ b/ge/generator/ge_generator.cc @@ -48,6 +48,7 @@ const char *const kVectorEngine = "VectorEngine"; const char *const kAIcoreEngine = "AIcoreEngine"; const char *const kFileNameSuffix = "online"; const char *const kAicpuAllshape = "_AllShape"; +constexpr char const *kAttrSupportDynamicShape = "support_dynamicshape"; const int64_t kDynamicDimValue = -2; std::map engine_type_map{ @@ -620,6 +621,26 @@ namespace { } return is_need; } + + Status CheckDynamicSupport(GeModelPtr &ge_model, const ComputeGraphPtr &graph) { + bool support_dynamic = true; + for (const auto &node : graph->GetDirectNode()) { + GE_CHECK_NOTNULL(node); + if (node->GetType() == DATA || node->GetType() == CONSTANT || node->GetType() == CONSTANTOP || + node->GetType() == NETOUTPUT) { + continue; + } + auto op_desc = node->GetOpDesc(); + GE_CHECK_NOTNULL(op_desc); + (void)AttrUtils::GetBool(op_desc, kAttrSupportDynamicShape, is_dynamic); + if (!is_dynamic) { + GELOGW("Node[%s] doesn't support dynamic shape.", node->GetName().c_str()); + (void)AttrUtils::SetBool(ge_model, kAttrSupportDynamicShape, false); + return SUCCESS; + } + } + return SUCCESS; + } } Status GeGenerator::CheckForSingleOp(OpDescPtr &op_desc, const vector &inputs, @@ -694,7 +715,9 @@ Status GeGenerator::BuildSingleOp(OpDescPtr &op_desc, const vector &in GELOGE(PARAM_INVALID, "GetSubgraphInstanceNameToModel is empty."); return PARAM_INVALID; } + const ComputeGraphPtr root_graph = ge_root_model->GetRootGraph(); GeModelPtr &ge_model = name_to_ge_model.begin()->second; + E_CHK_STATUS_RET_NOLOG(CheckDynamicSupport(ge_model, root_graph)); GELOGD("The opType in op_desc_tmp is [%s]", op_desc_tmp->GetType().c_str()); bool all_shape = false; From 16c2f091b742899b42bad90aaff2aeefb05db5e0 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 3 Feb 2021 20:58:14 +0800 Subject: [PATCH 2/3] Check dynamic support. --- ge/generator/ge_generator.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ge/generator/ge_generator.cc b/ge/generator/ge_generator.cc index 9d9fc23c..69ee2bfa 100644 --- a/ge/generator/ge_generator.cc +++ b/ge/generator/ge_generator.cc @@ -632,8 +632,8 @@ namespace { } auto op_desc = node->GetOpDesc(); GE_CHECK_NOTNULL(op_desc); - (void)AttrUtils::GetBool(op_desc, kAttrSupportDynamicShape, is_dynamic); - if (!is_dynamic) { + (void)AttrUtils::GetBool(op_desc, kAttrSupportDynamicShape, support_dynamic); + if (!support_dynamic) { GELOGW("Node[%s] doesn't support dynamic shape.", node->GetName().c_str()); (void)AttrUtils::SetBool(ge_model, kAttrSupportDynamicShape, false); return SUCCESS; @@ -717,7 +717,7 @@ Status GeGenerator::BuildSingleOp(OpDescPtr &op_desc, const vector &in } const ComputeGraphPtr root_graph = ge_root_model->GetRootGraph(); GeModelPtr &ge_model = name_to_ge_model.begin()->second; - E_CHK_STATUS_RET_NOLOG(CheckDynamicSupport(ge_model, root_graph)); + GE_CHK_STATUS_RET_NOLOG(CheckDynamicSupport(ge_model, root_graph)); GELOGD("The opType in op_desc_tmp is [%s]", op_desc_tmp->GetType().c_str()); bool all_shape = false; From 21649a285212dcd9381420d7379c5afd43ef4721 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 4 Feb 2021 17:04:35 +0800 Subject: [PATCH 3/3] Check dynamic support. --- ge/generator/ge_generator.cc | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/ge/generator/ge_generator.cc b/ge/generator/ge_generator.cc index 69ee2bfa..e9c2e6ab 100644 --- a/ge/generator/ge_generator.cc +++ b/ge/generator/ge_generator.cc @@ -624,6 +624,7 @@ namespace { Status CheckDynamicSupport(GeModelPtr &ge_model, const ComputeGraphPtr &graph) { bool support_dynamic = true; + bool is_dynamic = false; for (const auto &node : graph->GetDirectNode()) { GE_CHECK_NOTNULL(node); if (node->GetType() == DATA || node->GetType() == CONSTANT || node->GetType() == CONSTANTOP || @@ -632,13 +633,18 @@ namespace { } auto op_desc = node->GetOpDesc(); GE_CHECK_NOTNULL(op_desc); - (void)AttrUtils::GetBool(op_desc, kAttrSupportDynamicShape, support_dynamic); - if (!support_dynamic) { - GELOGW("Node[%s] doesn't support dynamic shape.", node->GetName().c_str()); - (void)AttrUtils::SetBool(ge_model, kAttrSupportDynamicShape, false); - return SUCCESS; + if (AttrUtils::HasAttr(op_desc, kAttrSupportDynamicShape)) { + is_dynamic = true; + (void) AttrUtils::GetBool(op_desc, kAttrSupportDynamicShape, support_dynamic); + if (!support_dynamic) { + GELOGW("Node[%s] doesn't support dynamic shape.", node->GetName().c_str()); + break; + } } } + if (is_dynamic) { + (void) AttrUtils::SetBool(ge_model, kAttrSupportDynamicShape, support_dynamic); + } return SUCCESS; } }