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

Function FindExcludeDuplicationNodes

tensorflow/core/graph/algorithm.cc:263–297  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

261}
262
263std::unordered_set<const Node*> FindExcludeDuplicationNodes(Graph* g,
264 std::unordered_set<const Node*>& visited) {
265 // Compute set of nodes that we need to traverse in order to reach
266 // the nodes in "nodes" by performing a breadth-first search from those
267 // nodes, and accumulating the visited nodes.
268 std::deque<const Node*> queue;
269 for (const Node* n : visited) {
270 VLOG(2) << "Reverse reach init: " << n->name();
271 queue.emplace_back(n);
272 }
273 while (!queue.empty()) {
274 const Node* n = queue.front();
275 queue.pop_front();
276 for (const Node* in : n->in_nodes()) {
277 if (visited.insert(in).second) {
278 queue.emplace_back(in);
279 }
280 }
281 }
282
283 // Make a pass over the graph to remove nodes not in "visited"
284 std::vector<Node*> all_nodes;
285 all_nodes.reserve(g->num_nodes());
286 for (Node* n : g->nodes()) {
287 all_nodes.emplace_back(n);
288 }
289
290 std::unordered_set<const Node*> excluded;
291 for (Node* n : all_nodes) {
292 if (visited.count(n) == 0 && !n->IsSource() && !n->IsSink()) {
293 excluded.emplace(n);
294 }
295 }
296 return excluded;
297}
298
299} // namespace tensorflow

Callers 1

PipelineGraphMethod · 0.85

Calls 14

IsSourceMethod · 0.80
IsSinkMethod · 0.80
nameMethod · 0.65
emplace_backMethod · 0.45
emptyMethod · 0.45
frontMethod · 0.45
pop_frontMethod · 0.45
in_nodesMethod · 0.45
insertMethod · 0.45
reserveMethod · 0.45
num_nodesMethod · 0.45
nodesMethod · 0.45

Tested by

no test coverage detected