diff --git a/mindspore/ccsrc/utils/graph_utils.cc b/mindspore/ccsrc/utils/graph_utils.cc index 6689719fccd..213abdf9030 100644 --- a/mindspore/ccsrc/utils/graph_utils.cc +++ b/mindspore/ccsrc/utils/graph_utils.cc @@ -25,7 +25,6 @@ #include #include #include -#include #include #include @@ -88,13 +87,14 @@ std::vector TopoSort(const AnfNodePtr &root, const SuccFunc &succ, c // search the cnodes inside this graph only std::vector BroadFirstSearchGraphCNodes(CNodePtr ret) { - std::queue todo; - todo.push(ret); + std::deque todo(1024); + todo.clear(); + todo.push_back(ret); std::vector sorted_nodes; auto seen = NewSeenGeneration(); while (!todo.empty()) { CNodePtr top = todo.front(); - todo.pop(); + todo.pop_front(); sorted_nodes.push_back(top); auto inputs = top->inputs(); for (auto &item : inputs) { @@ -103,7 +103,7 @@ std::vector BroadFirstSearchGraphCNodes(CNodePtr ret) { } if (item->isa()) { - todo.push(item->cast()); + todo.push_back(item->cast()); } item->seen_ = seen; }