MCPcopy Create free account
hub / github.com/Samsung/ONE / isDeadNode

Method isDeadNode

compiler/luci/lang/src/DeadNodeQueryService.cpp:39–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37};
38
39bool DeadNodeQueryServiceImpl::isDeadNode(loco::Node *node)
40{
41 auto g = node->graph();
42 auto input_nodes_vec = loco::input_nodes(g);
43 auto output_nodes_vec = loco::output_nodes(g);
44
45 auto input_nodes = std::set<loco::Node *>(input_nodes_vec.begin(), input_nodes_vec.end());
46 auto output_nodes = std::set<loco::Node *>(output_nodes_vec.begin(), output_nodes_vec.end());
47 auto active_nodes = loco::active_nodes(output_nodes_vec);
48
49 if (active_nodes.find(node) != active_nodes.end())
50 return false;
51 // input and output nodes are not dead node even if it is not active.
52 if (input_nodes.find(node) != input_nodes.end())
53 return false;
54
55 // if node is one of virtual mulitple outputs, we need to ask the real node
56 if (auto circle_node = dynamic_cast<luci::CircleNode *>(node))
57 {
58 VirtualOutputDetector d;
59 if (circle_node->accept(&d))
60 {
61 assert(node->arity() == 1);
62 loco::Node *real_node = node->arg(0);
63 if (active_nodes.find(real_node) != active_nodes.end())
64 return false;
65 if (input_nodes.find(real_node) != input_nodes.end())
66 return false;
67 }
68 }
69
70 return true;
71}
72
73} // namespace luci

Callers 3

TESTFunction · 0.80
inference_candidatesFunction · 0.80
runMethod · 0.80

Calls 10

input_nodesFunction · 0.85
output_nodesFunction · 0.85
active_nodesFunction · 0.85
graphMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
findMethod · 0.45
acceptMethod · 0.45
arityMethod · 0.45
argMethod · 0.45

Tested by 1

TESTFunction · 0.64