From 77eecae44026fcb5960c3f4392e2eecc334b93cd Mon Sep 17 00:00:00 2001 From: lichun Date: Mon, 11 Jan 2021 14:21:12 +0800 Subject: [PATCH 1/4] only check EXPERIMENTAL_DYNAMIC_PARTITION in some special scenes --- ge/graph/partition/dynamic_shape_partition.cc | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/ge/graph/partition/dynamic_shape_partition.cc b/ge/graph/partition/dynamic_shape_partition.cc index 95f13b6f..81295c84 100755 --- a/ge/graph/partition/dynamic_shape_partition.cc +++ b/ge/graph/partition/dynamic_shape_partition.cc @@ -44,18 +44,36 @@ #define REQUIRE_SUCCESS(cond, ...) REQUIRE(((cond) == SUCCESS), __VA_ARGS__) #define REQUIRE_GRAPH_SUCCESS(cond, ...) REQUIRE(((cond) == GRAPH_SUCCESS), __VA_ARGS__) -bool IsExperimental() { - const static bool kIsExperimental = (std::getenv("EXPERIMENTAL_DYNAMIC_PARTITION") != nullptr); - return kIsExperimental; -} - namespace ge { using Cluster = DynamicShapePartitioner::Cluster; using ClusterPtr = std::shared_ptr; +static bool IsContainResourceOp(const ComputeGraphPtr &root_graph) { + for (const auto &node : root_graph->GetAllNodes()) { + GE_CHECK_NOTNULL(node->GetOpDesc()); + for (const auto &input_desc : node->GetOpDesc()->GetAllInputsDesc()) { + auto type = input_desc.GetDataType(); + if (type == DT_STRING || type == DT_RESOURCE || type == DT_STRING_REF) { + if (std::getenv("EXPERIMENTAL_DYNAMIC_PARTITION") == nullptr) { + return false; + } + } + } + for (const auto &output_desc : node->GetOpDesc()->GetAllOutputsDesc()) { + auto type = output_desc.GetDataType(); + if (type == DT_STRING || type == DT_RESOURCE || type == DT_STRING_REF) { + if (std::getenv("EXPERIMENTAL_DYNAMIC_PARTITION") == nullptr) { + return false; + } + } + } + } + return true; +} + Status DynamicShapePartitioner::Partition() { REQUIRE_NOT_NULL(root_graph_, "Graph is nullptr."); - if (!IsExperimental()) { + if (!IsContainResourceOp(root_graph_)) { GELOGD("Skip dynamic shape partition as not in experimental mode."); REQUIRE(AttrUtils::SetBool(*root_graph_, ATTR_NAME_DYNAMIC_SHAPE_PARTITIONED, false), "Failed set dynamic shape partitioned flag on root graph."); From 0a719fc4b7727301d1e6f8126fa40a3bb6c2feea Mon Sep 17 00:00:00 2001 From: lichun Date: Wed, 13 Jan 2021 15:27:04 +0800 Subject: [PATCH 2/4] abandon using EXPERIMENTAL_DYNAMIC_PARTITION --- ge/graph/partition/dynamic_shape_partition.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ge/graph/partition/dynamic_shape_partition.cc b/ge/graph/partition/dynamic_shape_partition.cc index 81295c84..2ec501a8 100755 --- a/ge/graph/partition/dynamic_shape_partition.cc +++ b/ge/graph/partition/dynamic_shape_partition.cc @@ -56,6 +56,11 @@ static bool IsContainResourceOp(const ComputeGraphPtr &root_graph) { if (type == DT_STRING || type == DT_RESOURCE || type == DT_STRING_REF) { if (std::getenv("EXPERIMENTAL_DYNAMIC_PARTITION") == nullptr) { return false; + } else { + GELOGE(FAILED, "In dynamic shape scene, model contains data type:" + "DT_STRING/DT_RESOURCE/DT_STRING_REF may not be supported well " + "temporarily, please retry with \"unset EXPERIMENTAL_DYNAMIC_PARTITION\"."); + break; } } } @@ -64,6 +69,11 @@ static bool IsContainResourceOp(const ComputeGraphPtr &root_graph) { if (type == DT_STRING || type == DT_RESOURCE || type == DT_STRING_REF) { if (std::getenv("EXPERIMENTAL_DYNAMIC_PARTITION") == nullptr) { return false; + } else { + GELOGE(FAILED, "In dynamic shape scene, model contains data type:" + "DT_STRING/DT_RESOURCE/DT_STRING_REF may not be supported well " + "temporarily, please retry with \"unset EXPERIMENTAL_DYNAMIC_PARTITION\"."); + break; } } } From 4e391fe74180f05d82393e8e689840c04f5921c2 Mon Sep 17 00:00:00 2001 From: lichun Date: Wed, 13 Jan 2021 15:34:44 +0800 Subject: [PATCH 3/4] abandon using EXPERIMENTAL_DYNAMIC_PARTITION --- ge/graph/partition/dynamic_shape_partition.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ge/graph/partition/dynamic_shape_partition.cc b/ge/graph/partition/dynamic_shape_partition.cc index 2ec501a8..71a4b560 100755 --- a/ge/graph/partition/dynamic_shape_partition.cc +++ b/ge/graph/partition/dynamic_shape_partition.cc @@ -48,7 +48,7 @@ namespace ge { using Cluster = DynamicShapePartitioner::Cluster; using ClusterPtr = std::shared_ptr; -static bool IsContainResourceOp(const ComputeGraphPtr &root_graph) { +static bool IsInExperimentalMode(const ComputeGraphPtr &root_graph) { for (const auto &node : root_graph->GetAllNodes()) { GE_CHECK_NOTNULL(node->GetOpDesc()); for (const auto &input_desc : node->GetOpDesc()->GetAllInputsDesc()) { @@ -83,7 +83,7 @@ static bool IsContainResourceOp(const ComputeGraphPtr &root_graph) { Status DynamicShapePartitioner::Partition() { REQUIRE_NOT_NULL(root_graph_, "Graph is nullptr."); - if (!IsContainResourceOp(root_graph_)) { + if (!IsInExperimentalMode(root_graph_)) { GELOGD("Skip dynamic shape partition as not in experimental mode."); REQUIRE(AttrUtils::SetBool(*root_graph_, ATTR_NAME_DYNAMIC_SHAPE_PARTITIONED, false), "Failed set dynamic shape partitioned flag on root graph."); From de4c65bb94880c0e6f1ea0f21f82212fc360e838 Mon Sep 17 00:00:00 2001 From: lichun Date: Wed, 13 Jan 2021 16:17:43 +0800 Subject: [PATCH 4/4] abandon using EXPERIMENTAL_DYNAMIC_PARTITION --- ge/graph/partition/dynamic_shape_partition.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ge/graph/partition/dynamic_shape_partition.cc b/ge/graph/partition/dynamic_shape_partition.cc index 71a4b560..6c81b21f 100755 --- a/ge/graph/partition/dynamic_shape_partition.cc +++ b/ge/graph/partition/dynamic_shape_partition.cc @@ -57,7 +57,7 @@ static bool IsInExperimentalMode(const ComputeGraphPtr &root_graph) { if (std::getenv("EXPERIMENTAL_DYNAMIC_PARTITION") == nullptr) { return false; } else { - GELOGE(FAILED, "In dynamic shape scene, model contains data type:" + GEEVENT("In dynamic shape scene, model contains data type:" "DT_STRING/DT_RESOURCE/DT_STRING_REF may not be supported well " "temporarily, please retry with \"unset EXPERIMENTAL_DYNAMIC_PARTITION\"."); break; @@ -70,7 +70,7 @@ static bool IsInExperimentalMode(const ComputeGraphPtr &root_graph) { if (std::getenv("EXPERIMENTAL_DYNAMIC_PARTITION") == nullptr) { return false; } else { - GELOGE(FAILED, "In dynamic shape scene, model contains data type:" + GEEVENT("In dynamic shape scene, model contains data type:" "DT_STRING/DT_RESOURCE/DT_STRING_REF may not be supported well " "temporarily, please retry with \"unset EXPERIMENTAL_DYNAMIC_PARTITION\"."); break;