From 78f23d38a1fd7fd260ffe7894103184d3db4563e Mon Sep 17 00:00:00 2001 From: wuyongkang Date: Sun, 28 Jun 2020 16:50:16 +0800 Subject: [PATCH] Optimized TopoSort --- mindspore/ccsrc/utils/graph_utils.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mindspore/ccsrc/utils/graph_utils.cc b/mindspore/ccsrc/utils/graph_utils.cc index e956498a3f2..03ac14573df 100644 --- a/mindspore/ccsrc/utils/graph_utils.cc +++ b/mindspore/ccsrc/utils/graph_utils.cc @@ -23,10 +23,10 @@ #include #include #include -#include #include #include #include +#include #include #include "common/utils.h" @@ -37,9 +37,11 @@ namespace mindspore { std::vector TopoSort(const AnfNodePtr &root, const SuccFunc &succ, const IncludeFunc &include) { size_t seen = NewSeenGeneration(); - std::list todo(1, root); + std::deque todo(1024); std::unordered_map rank; std::vector res; + todo.clear(); + todo.push_back(root); while (!todo.empty()) { AnfNodePtr node = todo.back();