From d75417c9d4b6b9f995d958c23b308d79ef7eb65b Mon Sep 17 00:00:00 2001 From: zhou_lili Date: Fri, 15 Jan 2021 17:00:20 +0800 Subject: [PATCH] action of remove const data has be done by subgraph_const_migration_pass.cc --- ge/CMakeLists.txt | 2 - ge/ge_inference.mk | 1 - ge/ge_runner.mk | 1 - ge/graph/manager/graph_manager.cc | 3 - .../no_data_out_const_elimination_pass.cc | 36 -------- .../no_data_out_const_elimination_pass.h | 31 ------- tests/ut/ge/CMakeLists.txt | 2 - ...ata_out_const_elimination_pass_unittest.cc | 82 ------------------- 8 files changed, 158 deletions(-) delete mode 100644 ge/graph/passes/no_data_out_const_elimination_pass.cc delete mode 100644 ge/graph/passes/no_data_out_const_elimination_pass.h delete mode 100644 tests/ut/ge/graph/passes/no_data_out_const_elimination_pass_unittest.cc diff --git a/ge/CMakeLists.txt b/ge/CMakeLists.txt index 436c30ea..a8eabf05 100755 --- a/ge/CMakeLists.txt +++ b/ge/CMakeLists.txt @@ -204,7 +204,6 @@ set(TRAIN_SRC_LIST "graph/passes/constant_fuse_same_pass.cc" "graph/passes/fuse_data_nodes_with_common_input_pass.cc" "graph/passes/remove_same_const_pass.cc" - "graph/passes/no_data_out_const_elimination_pass.cc" "graph/passes/useless_control_out_remove_pass.cc" "graph/passes/control_trigger_pass.cc" "graph/passes/dimension_adjust_pass.cc" @@ -583,7 +582,6 @@ set(INFER_SRC_LIST "graph/passes/addn_pass.cc" "graph/passes/common_subexpression_elimination_pass.cc" "graph/passes/remove_same_const_pass.cc" - "graph/passes/no_data_out_const_elimination_pass.cc" "graph/passes/useless_control_out_remove_pass.cc" "graph/passes/transop_symmetry_elimination_pass.cc" "graph/passes/save_pass.cc" diff --git a/ge/ge_inference.mk b/ge/ge_inference.mk index 1830e847..6f9e60db 100755 --- a/ge/ge_inference.mk +++ b/ge/ge_inference.mk @@ -194,7 +194,6 @@ OMG_HOST_SRC_FILES := \ graph/passes/cond_pass.cc \ graph/passes/cond_remove_pass.cc \ graph/passes/remove_same_const_pass.cc \ - graph/passes/no_data_out_const_elimination_pass.cc \ graph/passes/useless_control_out_remove_pass.cc \ graph/passes/for_pass.cc \ graph/passes/enter_pass.cc \ diff --git a/ge/ge_runner.mk b/ge/ge_runner.mk index 9dcac211..460d5068 100644 --- a/ge/ge_runner.mk +++ b/ge/ge_runner.mk @@ -129,7 +129,6 @@ LIBGE_LOCAL_SRC_FILES := \ graph/passes/constant_fuse_same_pass.cc \ graph/passes/fuse_data_nodes_with_common_input_pass.cc \ graph/passes/remove_same_const_pass.cc \ - graph/passes/no_data_out_const_elimination_pass.cc \ graph/passes/useless_control_out_remove_pass.cc \ graph/passes/control_trigger_pass.cc \ graph/passes/dimension_adjust_pass.cc \ diff --git a/ge/graph/manager/graph_manager.cc b/ge/graph/manager/graph_manager.cc index 322ceecc..b0d412dc 100755 --- a/ge/graph/manager/graph_manager.cc +++ b/ge/graph/manager/graph_manager.cc @@ -71,7 +71,6 @@ #include "graph/passes/remove_same_const_pass.h" #include "graph/passes/reshape_recovery_pass.h" #include "graph/passes/reshape_remove_pass.h" -#include "graph/passes/no_data_out_const_elimination_pass.h" #include "graph/passes/same_transdata_breadth_fusion_pass.h" #include "graph/passes/subgraph_pass.h" #include "graph/passes/switch_data_edges_bypass.h" @@ -2249,9 +2248,7 @@ Status GraphManager::OptimizeStage1(ge::ComputeGraphPtr &compute_graph) { NamesToPass node_pass; GE_TIMESTAMP_START(node_pass); IdentityPass identity_force_pass(false); // after SwitchToStreamSwitchPass - NoDataOutConstEliminationPass no_data_out_const_elimination_pass; node_pass.emplace_back("IdentityPass", &identity_force_pass); - node_pass.emplace_back("NoDataOutConstEliminationPass", &no_data_out_const_elimination_pass); ret = GEPass(compute_graph).Run(node_pass); GE_TIMESTAMP_END(node_pass, "GraphPrepare::node_pass"); if (ret != SUCCESS) { diff --git a/ge/graph/passes/no_data_out_const_elimination_pass.cc b/ge/graph/passes/no_data_out_const_elimination_pass.cc deleted file mode 100644 index c55148bd..00000000 --- a/ge/graph/passes/no_data_out_const_elimination_pass.cc +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Copyright 2021 Huawei Technologies Co., Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "graph/passes/no_data_out_const_elimination_pass.h" - -namespace ge { -Status NoDataOutConstEliminationPass::Run(NodePtr &node) { - GE_CHECK_NOTNULL(node); - GELOGD("RemoveConstWithoutDataPass running of %s.", node->GetName().c_str()); - if (node->GetType() == CONSTANT || node->GetType() == CONSTANTOP) { - GE_CHECK_NOTNULL(node->GetOpDesc()); - // delete const which has no input and no output of data - if (node->GetOpDesc()->GetInputsSize() == 0 && node->GetOutDataNodes().size() == 0) { - GELOGI("Remove const %s.", node->GetName().c_str()); - if (IsolateAndDeleteNode(node, {}) != SUCCESS) { - GELOGE(FAILED, "IsolateAndDeleteNode %s failed.", node->GetName().c_str()); - return FAILED; - } - } - } - return SUCCESS; -} -} // namespace ge diff --git a/ge/graph/passes/no_data_out_const_elimination_pass.h b/ge/graph/passes/no_data_out_const_elimination_pass.h deleted file mode 100644 index 112c4867..00000000 --- a/ge/graph/passes/no_data_out_const_elimination_pass.h +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright 2021 Huawei Technologies Co., Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GE_GRAPH_PASSES_REMOVE_CONST_WITHOUT_DATA_PASS_H_ -#define GE_GRAPH_PASSES_REMOVE_CONST_WITHOUT_DATA_PASS_H_ - -#include "graph/passes/base_pass.h" -#include "framework/common/debug/ge_log.h" -#include "framework/common/util.h" - -namespace ge { -class NoDataOutConstEliminationPass : public BaseNodePass { - public: - Status Run(ge::NodePtr &node) override; -}; -} // namespace ge - -#endif // GE_GRAPH_PASSES_REMOVE_CONST_WITHOUT_DATA_PASS_H_ diff --git a/tests/ut/ge/CMakeLists.txt b/tests/ut/ge/CMakeLists.txt index 0d4f6a66..91a6620d 100755 --- a/tests/ut/ge/CMakeLists.txt +++ b/tests/ut/ge/CMakeLists.txt @@ -179,7 +179,6 @@ set(COMMON_SRC_FILES "${GE_CODE_DIR}/ge/graph/passes/replace_transshape_pass.cc" "${GE_CODE_DIR}/ge/graph/passes/constant_fuse_same_pass.cc" "${GE_CODE_DIR}/ge/graph/passes/fuse_data_nodes_with_common_input_pass.cc" - "${GE_CODE_DIR}/ge/graph/passes/no_data_out_const_elimination_pass.cc" "${GE_CODE_DIR}/ge/graph/passes/print_op_pass.cc" "${GE_CODE_DIR}/ge/graph/passes/no_use_reshape_remove_pass.cc" "${GE_CODE_DIR}/ge/graph/passes/iterator_op_pass.cc" @@ -619,7 +618,6 @@ set(PASS_TEST_FILES "graph/passes/transop_nearby_allreduce_fusion_pass_unittest.cc" "graph/passes/constant_folding_pass_unittest.cc" "graph/passes/fuse_data_nodes_with_common_input_pass_unittest.cc" - "graph/passes/no_data_out_const_elimination_pass_unittest.cc" "graph/passes/stop_gradient_pass_unittest.cc" "graph/passes/prevent_gradient_pass_unittest.cc" "graph/passes/identity_pass_unittest.cc" diff --git a/tests/ut/ge/graph/passes/no_data_out_const_elimination_pass_unittest.cc b/tests/ut/ge/graph/passes/no_data_out_const_elimination_pass_unittest.cc deleted file mode 100644 index 2fa80e2f..00000000 --- a/tests/ut/ge/graph/passes/no_data_out_const_elimination_pass_unittest.cc +++ /dev/null @@ -1,82 +0,0 @@ -/** - * Copyright 2021 Huawei Technologies Co., Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "graph/passes/no_data_out_const_elimination_pass.h" - -#include -#include -#include -#include - -#include "common/ge_inner_error_codes.h" -#include "graph/utils/graph_utils.h" - -namespace ge { - -class UtestNoDataOutConstEliminationPass : public testing::Test { -protected: - void SetUp() {} - void TearDown() {} - -public: - NodePtr MakeNode(const ComputeGraphPtr &graph, uint32_t in_num, uint32_t out_num, string name, string type) { - GeTensorDesc test_desc(GeShape(), FORMAT_NCHW, DT_FLOAT); - auto op_desc = std::make_shared(name, type); - for (auto i = 0; i < in_num; ++i) { - op_desc->AddInputDesc(test_desc); - } - for (auto i = 0; i < out_num; ++i) { - op_desc->AddOutputDesc(test_desc); - } - return graph->AddNode(op_desc); - } -}; - -/// graph with subgraph -/// const1 -/// |(control) -/// const2 -/// | -/// output -TEST_F(UtestNoDataOutConstEliminationPass, succ_graph1) { - ComputeGraphPtr graph = std::make_shared("test"); - auto const_node1 = MakeNode(graph, 0, 1, "const_node1", "Const"); - auto const_node2 = MakeNode(graph, 1, 1, "const_node2", "Const"); - auto output_node = MakeNode(graph, 1, 0, "output_node", "NetOutput"); - GeTensorDesc tensor_desc(GeShape({1,3,224,224}), FORMAT_NCHW, DT_FLOAT); - - const_node1->GetOpDesc()->UpdateOutputDesc(0, tensor_desc); - const_node2->GetOpDesc()->UpdateInputDesc(0, tensor_desc); - const_node2->GetOpDesc()->UpdateOutputDesc(0, tensor_desc); - output_node->GetOpDesc()->UpdateInputDesc(0, tensor_desc); - - GraphUtils::AddEdge(const_node1->GetOutControlAnchor(), const_node2->GetInControlAnchor()); - GraphUtils::AddEdge(const_node2->GetOutDataAnchor(0), output_node->GetInDataAnchor(0)); - - GEPass pass(graph); - NamesToPass node_pass; - NoDataOutConstEliminationPass no_data_out_const_elimination_pass; - node_pass.emplace_back("NoDataOutConstEliminationPass", &no_data_out_const_elimination_pass); - auto const1 = graph->FindNode("const_node1"); - EXPECT_NE(const1, nullptr); - EXPECT_TRUE(const1->GetInDataNodes().empty()); - EXPECT_TRUE(const1->GetOutDataNodes().empty()); - EXPECT_EQ(pass.Run(node_pass), SUCCESS); - // after pass, const1 will be delete - const1 = graph->FindNode("const_node1"); - EXPECT_EQ(const1, nullptr); -} -} // namespace ge