From 7bc0ac619bc046b145d8351e58ce06662002d9ed Mon Sep 17 00:00:00 2001 From: Zhang Qinghua Date: Mon, 23 Nov 2020 11:03:16 +0800 Subject: [PATCH] Remove return node checking for SuccDeeperSimple() including function. --- mindspore/core/ir/graph_utils.cc | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/mindspore/core/ir/graph_utils.cc b/mindspore/core/ir/graph_utils.cc index 6a9b17b128c..cff06ee8915 100644 --- a/mindspore/core/ir/graph_utils.cc +++ b/mindspore/core/ir/graph_utils.cc @@ -34,18 +34,17 @@ namespace mindspore { std::vector TopoSort(const AnfNodePtr &root, const SuccFunc &succ, const IncludeFunc &include) { + std::vector res; + if (root == nullptr) { + return res; + } size_t seen = NewSeenGeneration(); std::deque todo(1024); - std::vector res; todo.clear(); todo.push_back(root); while (!todo.empty()) { AnfNodePtr node = todo.back(); - if (node == nullptr) { - todo.pop_back(); - continue; - } if (node->extra_seen_ == seen) { // We use extra_seen_ as finish flag todo.pop_back(); continue; @@ -65,10 +64,8 @@ std::vector TopoSort(const AnfNodePtr &root, const SuccFunc &succ, c node->seen_ = seen; if (incl == FOLLOW) { auto succs = succ(node); - (void)std::copy_if(succs.begin(), succs.end(), std::back_inserter(todo), [seen](const AnfNodePtr &next) { - return next != nullptr && next->seen_ != seen && - (next->func_graph() == nullptr || next->func_graph()->get_return() != next); - }); + (void)std::copy_if(succs.begin(), succs.end(), std::back_inserter(todo), + [seen](const AnfNodePtr &next) { return next != nullptr && next->seen_ != seen; }); } else if (incl > EXCLUDE) { // Not NOFOLLOW or EXCLUDE MS_LOG(EXCEPTION) << "The result of include(node) must be one of: \"follow\", \"nofollow\", \"exclude\""; }