forked from mindspore-Ecosystem/mindspore
commit
77d23a1b17
|
@ -23,10 +23,10 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <stack>
|
#include <stack>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <list>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
|
#include <deque>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
#include "common/utils.h"
|
#include "common/utils.h"
|
||||||
|
@ -37,9 +37,11 @@
|
||||||
namespace mindspore {
|
namespace mindspore {
|
||||||
std::vector<AnfNodePtr> TopoSort(const AnfNodePtr &root, const SuccFunc &succ, const IncludeFunc &include) {
|
std::vector<AnfNodePtr> TopoSort(const AnfNodePtr &root, const SuccFunc &succ, const IncludeFunc &include) {
|
||||||
size_t seen = NewSeenGeneration();
|
size_t seen = NewSeenGeneration();
|
||||||
std::list<AnfNodePtr> todo(1, root);
|
std::deque<AnfNodePtr> todo(1024);
|
||||||
std::unordered_map<AnfNodePtr, size_t> rank;
|
std::unordered_map<AnfNodePtr, size_t> rank;
|
||||||
std::vector<AnfNodePtr> res;
|
std::vector<AnfNodePtr> res;
|
||||||
|
todo.clear();
|
||||||
|
todo.push_back(root);
|
||||||
|
|
||||||
while (!todo.empty()) {
|
while (!todo.empty()) {
|
||||||
AnfNodePtr node = todo.back();
|
AnfNodePtr node = todo.back();
|
||||||
|
|
Loading…
Reference in New Issue