From 537b1bc8bc801ea59e67c3bd8f16dde6cc3f2ff6 Mon Sep 17 00:00:00 2001 From: wxl Date: Tue, 16 Mar 2021 13:56:54 +0800 Subject: [PATCH 1/8] fix bug --- ge/graph/load/model_manager/model_manager.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ge/graph/load/model_manager/model_manager.cc b/ge/graph/load/model_manager/model_manager.cc index 97ad0054..3b324a1a 100755 --- a/ge/graph/load/model_manager/model_manager.cc +++ b/ge/graph/load/model_manager/model_manager.cc @@ -299,9 +299,9 @@ Status ModelManager::LoadModelOnline(uint32_t &model_id, const shared_ptrGetSubgraphInstanceNameToModel(); string model_name = ""; - bool is_shape_unknown = ge_root_model->GetRootGraph()->GetGraphUnknownFlag(); - // if multi subgraph is known, do hybrid load process - if (is_shape_unknown || GetContext().GetHostExecFlag() || (name_to_model.size() > 1)) { + bool is_shape_unknown = false; + (void)AttrUtils::GetBool(ge_root_model->GetRootGraph(), ATTR_NAME_DYNAMIC_SHAPE_PARTITIONED, is_shape_unknown); + if (is_shape_unknown || GetContext().GetHostExecFlag()) { return DoLoadHybridModelOnline(model_id, model_name, ge_root_model, listener); } From 4d68daac2328726d0a64f1b536fef5931cfe18cf Mon Sep 17 00:00:00 2001 From: wxl Date: Tue, 16 Mar 2021 15:00:03 +0800 Subject: [PATCH 2/8] fix bug of dynamic shape load error --- ge/graph/passes/prune_pass.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ge/graph/passes/prune_pass.cc b/ge/graph/passes/prune_pass.cc index 3c95f3b1..111e01d4 100644 --- a/ge/graph/passes/prune_pass.cc +++ b/ge/graph/passes/prune_pass.cc @@ -27,7 +27,7 @@ namespace ge { Status PrunePass::Run(ge::ComputeGraphPtr graph) { - GELOGD("PrunePass Start, graph is [%s]", graph->GetName().c_str()); + GELOGD("PrunePass Start, graph is [%s].", graph->GetName().c_str()); if (graph == nullptr) { GELOGE(GE_GRAPH_ISNULL, "input compute graph is NULL."); return GE_GRAPH_ISNULL; @@ -42,7 +42,7 @@ Status PrunePass::Run(ge::ComputeGraphPtr graph) { } } if (out_nodes.empty()) { - GELOGW("graph [%s] does not contain NETOUTPUT type node,no return value. Do nothing!", graph->GetName().c_str()); + GELOGW("graph [%s] does not contain NETOUTPUT type node, no return value. Do nothing!", graph->GetName().c_str()); return ge::SUCCESS; } From 952581264e5617622f6236abd5904fe49eaa2013 Mon Sep 17 00:00:00 2001 From: wxl Date: Tue, 16 Mar 2021 15:26:12 +0800 Subject: [PATCH 3/8] fix bug of dynamic shape load error --- ge/graph/passes/identity_pass.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ge/graph/passes/identity_pass.cc b/ge/graph/passes/identity_pass.cc index 5a54e391..91452bf4 100755 --- a/ge/graph/passes/identity_pass.cc +++ b/ge/graph/passes/identity_pass.cc @@ -54,10 +54,10 @@ Status CheckIdentityUsable(const NodePtr &node, bool &usable) { } GE_CHK_STATUS_RET(GetOriginalType(in_node, node_type), - "Failed to get node type from node %s", node->GetName().c_str()); + "Failed to get node type from node %s.", node->GetName().c_str()); bool need_skip = (node_type != SWITCH) && (node_type != REFSWITCH) && (node_type != SWITCHN); if (need_skip) { - GELOGD("skip identity %s connected to switch", node->GetName().c_str()); + GELOGD("skip identity %s connected to switch.", node->GetName().c_str()); break; } GE_CHECK_NOTNULL(node->GetOutControlAnchor()); From 29662329961e57842e0fb8469c2fe090c5efb692 Mon Sep 17 00:00:00 2001 From: wxl Date: Wed, 17 Mar 2021 14:09:48 +0800 Subject: [PATCH 4/8] fix bug of dynamic shape load error --- ge/graph/load/model_manager/model_manager.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ge/graph/load/model_manager/model_manager.cc b/ge/graph/load/model_manager/model_manager.cc index 3b324a1a..aa2de7e6 100755 --- a/ge/graph/load/model_manager/model_manager.cc +++ b/ge/graph/load/model_manager/model_manager.cc @@ -299,9 +299,10 @@ Status ModelManager::LoadModelOnline(uint32_t &model_id, const shared_ptrGetSubgraphInstanceNameToModel(); string model_name = ""; - bool is_shape_unknown = false; + bool is_shape_unknown = ge_root_model->GetRootGraph()->GetGraphUnknownFlag(); + bool is_dsp_partitioned_graph = false; (void)AttrUtils::GetBool(ge_root_model->GetRootGraph(), ATTR_NAME_DYNAMIC_SHAPE_PARTITIONED, is_shape_unknown); - if (is_shape_unknown || GetContext().GetHostExecFlag()) { + if (is_shape_unknown || is_dsp_partitioned_graph || GetContext().GetHostExecFlag()) { return DoLoadHybridModelOnline(model_id, model_name, ge_root_model, listener); } From f8acefb43d7c15781590588ff22c581fe428d4ad Mon Sep 17 00:00:00 2001 From: wxl Date: Wed, 17 Mar 2021 14:13:18 +0800 Subject: [PATCH 5/8] fix bug of dynamic shape load error --- ge/graph/passes/identity_pass.cc | 4 ++-- ge/graph/passes/prune_pass.cc | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ge/graph/passes/identity_pass.cc b/ge/graph/passes/identity_pass.cc index 91452bf4..5a54e391 100755 --- a/ge/graph/passes/identity_pass.cc +++ b/ge/graph/passes/identity_pass.cc @@ -54,10 +54,10 @@ Status CheckIdentityUsable(const NodePtr &node, bool &usable) { } GE_CHK_STATUS_RET(GetOriginalType(in_node, node_type), - "Failed to get node type from node %s.", node->GetName().c_str()); + "Failed to get node type from node %s", node->GetName().c_str()); bool need_skip = (node_type != SWITCH) && (node_type != REFSWITCH) && (node_type != SWITCHN); if (need_skip) { - GELOGD("skip identity %s connected to switch.", node->GetName().c_str()); + GELOGD("skip identity %s connected to switch", node->GetName().c_str()); break; } GE_CHECK_NOTNULL(node->GetOutControlAnchor()); diff --git a/ge/graph/passes/prune_pass.cc b/ge/graph/passes/prune_pass.cc index 111e01d4..50defbed 100644 --- a/ge/graph/passes/prune_pass.cc +++ b/ge/graph/passes/prune_pass.cc @@ -42,7 +42,7 @@ Status PrunePass::Run(ge::ComputeGraphPtr graph) { } } if (out_nodes.empty()) { - GELOGW("graph [%s] does not contain NETOUTPUT type node, no return value. Do nothing!", graph->GetName().c_str()); + GELOGW("graph [%s] does not contain NETOUTPUT type node,no return value. Do nothing!", graph->GetName().c_str()); return ge::SUCCESS; } From d74426596a183090394386bc083dcd0aa7d21c78 Mon Sep 17 00:00:00 2001 From: wxl Date: Wed, 17 Mar 2021 14:14:04 +0800 Subject: [PATCH 6/8] fix bug of dynamic shape load error --- ge/graph/passes/prune_pass.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ge/graph/passes/prune_pass.cc b/ge/graph/passes/prune_pass.cc index 50defbed..3c95f3b1 100644 --- a/ge/graph/passes/prune_pass.cc +++ b/ge/graph/passes/prune_pass.cc @@ -27,7 +27,7 @@ namespace ge { Status PrunePass::Run(ge::ComputeGraphPtr graph) { - GELOGD("PrunePass Start, graph is [%s].", graph->GetName().c_str()); + GELOGD("PrunePass Start, graph is [%s]", graph->GetName().c_str()); if (graph == nullptr) { GELOGE(GE_GRAPH_ISNULL, "input compute graph is NULL."); return GE_GRAPH_ISNULL; From e20387891086ca2ae9e4c1ece29d1df17d564f31 Mon Sep 17 00:00:00 2001 From: wxl Date: Wed, 17 Mar 2021 22:42:39 +0800 Subject: [PATCH 7/8] fix bug of dynamic shape load error --- ge/graph/load/model_manager/model_manager.cc | 16 ++++++++++++---- ge/graph/load/model_manager/model_manager.h | 3 +++ tests/ut/ge/graph/load/model_manager_unittest.cc | 9 +++++++++ 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/ge/graph/load/model_manager/model_manager.cc b/ge/graph/load/model_manager/model_manager.cc index aa2de7e6..27cbd526 100755 --- a/ge/graph/load/model_manager/model_manager.cc +++ b/ge/graph/load/model_manager/model_manager.cc @@ -286,6 +286,17 @@ ge::Status ModelManager::DoLoadHybridModelOnline(uint32_t model_id, const string return SUCCESS; } +bool ModelManager::IsNeedHybridLoad(ge::GeRootModel &ge_root_model) { + auto root_graph = ge_root_model.GetRootGraph(); + if (root_graph == nullptr) { + GELOGE(FAILED, "no model on root model"); + return false; + } + bool is_shape_unknown = root_graph->GetGraphUnknownFlag(); + bool is_dsp_partitioned_graph = false; + (void)AttrUtils::GetBool(root_graph, ATTR_NAME_DYNAMIC_SHAPE_PARTITIONED, is_dsp_partitioned_graph); + return is_shape_unknown || is_dsp_partitioned_graph || GetContext().GetHostExecFlag(); +} /// /// @ingroup domi_ome /// @brief load model online @@ -299,10 +310,7 @@ Status ModelManager::LoadModelOnline(uint32_t &model_id, const shared_ptrGetSubgraphInstanceNameToModel(); string model_name = ""; - bool is_shape_unknown = ge_root_model->GetRootGraph()->GetGraphUnknownFlag(); - bool is_dsp_partitioned_graph = false; - (void)AttrUtils::GetBool(ge_root_model->GetRootGraph(), ATTR_NAME_DYNAMIC_SHAPE_PARTITIONED, is_shape_unknown); - if (is_shape_unknown || is_dsp_partitioned_graph || GetContext().GetHostExecFlag()) { + if (IsNeedHybridLoad(*ge_root_model)) { return DoLoadHybridModelOnline(model_id, model_name, ge_root_model, listener); } diff --git a/ge/graph/load/model_manager/model_manager.h b/ge/graph/load/model_manager/model_manager.h index f2d55db7..735e4a7a 100755 --- a/ge/graph/load/model_manager/model_manager.h +++ b/ge/graph/load/model_manager/model_manager.h @@ -294,6 +294,7 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ModelManager { std::vector &output_dims); bool IsDynamicShape(uint32_t model_id); + bool IsNeedHybridLoad(ge::GeRootModel &ge_root_model); ge::Status GetOpDescInfo(uint32_t device_id, uint32_t stream_id, uint32_t task_id, OpDescInfo &op_desc_info); ge::Status EnableExceptionDump(const std::map &options); @@ -339,6 +340,8 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ModelManager { ge::Status DeleteModel(uint32_t id); void GenModelId(uint32_t *id); + bool IsNeedHybridLoad(); + std::map> model_map_; std::map> hybrid_model_map_; diff --git a/tests/ut/ge/graph/load/model_manager_unittest.cc b/tests/ut/ge/graph/load/model_manager_unittest.cc index 0e65954d..342f6362 100644 --- a/tests/ut/ge/graph/load/model_manager_unittest.cc +++ b/tests/ut/ge/graph/load/model_manager_unittest.cc @@ -151,6 +151,15 @@ class DModelListener : public ModelListener { uint32_t OnComputeDone(uint32_t model_id, uint32_t data_index, uint32_t resultCode) { return 0; } }; +TEST_F(UtestModelManagerModelManager, case_is_need_hybrid_load) { + ModelManager mm; + uint32_t model_id = 0; + ComputeGraphPtr root_graph = std::make_shared("graph"); + ge::GeRootModel model; + EXPECT_EQ(mm.IsNeedHybridLoad(model), false); + model.SetRootGraph(root_graph); + EXPECT_EQ(mm.IsNeedHybridLoad(model), false); +} TEST_F(UtestModelManagerModelManager, case_load_incorrect_param) { ModelManager mm; From 1751f0e462cf1e484891e60356bf8584e3c5b9f5 Mon Sep 17 00:00:00 2001 From: wxl Date: Fri, 19 Mar 2021 13:57:34 +0800 Subject: [PATCH 8/8] fix bug of dynamic shape load error --- ge/graph/load/model_manager/model_manager.h | 1 - 1 file changed, 1 deletion(-) diff --git a/ge/graph/load/model_manager/model_manager.h b/ge/graph/load/model_manager/model_manager.h index 735e4a7a..b537943b 100755 --- a/ge/graph/load/model_manager/model_manager.h +++ b/ge/graph/load/model_manager/model_manager.h @@ -340,7 +340,6 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ModelManager { ge::Status DeleteModel(uint32_t id); void GenModelId(uint32_t *id); - bool IsNeedHybridLoad(); std::map> model_map_;