ONE - On-device Neural Engine
Loading...
Searching...
No Matches
luci::DeadNodeQueryServiceImpl Struct Referencefinal

#include <DeadNodeQueryService.h>

Collaboration diagram for luci::DeadNodeQueryServiceImpl:

Public Member Functions

bool isDeadNode (loco::Node *node) final
 Check if the node is dead node.
 
- Public Member Functions inherited from logo::DeadNodeQueryService
virtual ~DeadNodeQueryService ()=default
 
- Public Member Functions inherited from loco::DialectService
virtual ~DialectService ()=default
 

Detailed Description

Definition at line 27 of file DeadNodeQueryService.h.

Member Function Documentation

◆ isDeadNode()

bool luci::DeadNodeQueryServiceImpl::isDeadNode ( loco::Node node)
finalvirtual

Check if the node is dead node.

Implements logo::DeadNodeQueryService.

Definition at line 39 of file DeadNodeQueryService.cpp.

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}
Logical unit of computation.
Definition Node.h:54
virtual Node * arg(uint32_t N) const =0
Access N-th argument node.
Graph * graph(void)
Definition Node.h:70
virtual uint32_t arity(void) const =0
Return the number of arguments.
std::vector< Node * > input_nodes(const Graph *)
Definition Graph.cpp:71
std::set< loco::Node * > active_nodes(const std::vector< loco::Node * > &roots)
Enumerate all the nodes required to compute "roots".
std::vector< Node * > output_nodes(Graph *)
Definition Graph.cpp:101

References loco::active_nodes(), loco::Node::arg(), loco::Node::arity(), loco::Node::graph(), loco::input_nodes(), and loco::output_nodes().


The documentation for this struct was generated from the following files: