MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / ForwardDFS

Function ForwardDFS

tensorflow/compiler/jit/graphcycles/graphcycles.cc:201–227  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

199}
200
201static bool ForwardDFS(GraphCycles::Rep* r, int32 n, int32 upper_bound) {
202 // Avoid recursion since stack space might be limited.
203 // We instead keep a stack of nodes to visit.
204 r->deltaf_.clear();
205 r->stack_.clear();
206 r->stack_.push_back(n);
207 while (!r->stack_.empty()) {
208 n = r->stack_.back();
209 r->stack_.pop_back();
210 Node* nn = r->nodes_[n];
211 if (nn->visited) continue;
212
213 nn->visited = true;
214 r->deltaf_.push_back(n);
215
216 for (auto w : nn->out.GetSequence()) {
217 Node* nw = r->nodes_[w];
218 if (nw->rank == upper_bound) {
219 return false; // Cycle
220 }
221 if (!nw->visited && nw->rank < upper_bound) {
222 r->stack_.push_back(w);
223 }
224 }
225 }
226 return true;
227}
228
229static void BackwardDFS(GraphCycles::Rep* r, int32 n, int32 lower_bound) {
230 r->deltab_.clear();

Callers 2

InsertEdgeMethod · 0.85
IsReachableNonConstMethod · 0.85

Calls 6

pop_backMethod · 0.80
GetSequenceMethod · 0.80
clearMethod · 0.45
push_backMethod · 0.45
emptyMethod · 0.45
backMethod · 0.45

Tested by

no test coverage detected