ONE - On-device Neural Engine
Loading...
Searching...
No Matches
logo::RemoveDeadNodeWithQueryPass Struct Referencefinal

#include <RemoveDeadNodeWithQueryPass.h>

Collaboration diagram for logo::RemoveDeadNodeWithQueryPass:

Public Member Functions

const char * name (void) const final
 
bool run (loco::Graph *g)
 Run the pass.
 
- Public Member Functions inherited from logo::Pass
virtual ~Pass ()=default
 

Detailed Description

Definition at line 25 of file RemoveDeadNodeWithQueryPass.h.

Member Function Documentation

◆ name()

const char * logo::RemoveDeadNodeWithQueryPass::name ( void  ) const
inlinefinalvirtual

Reimplemented from logo::Pass.

Definition at line 27 of file RemoveDeadNodeWithQueryPass.h.

27{ return "RemoveDeadNodeWithQueryPass"; }

◆ run()

bool logo::RemoveDeadNodeWithQueryPass::run ( loco::Graph graph)
virtual

Run the pass.

Returns
false if there was nothing changed

Implements logo::Pass.

Definition at line 29 of file RemoveDeadNodeWithQueryPass.cpp.

30{
31 // Let's enumerate nodes required to compute output nodes
33
34 // List dead(= non-active) nodes candidates
35 std::set<loco::Node *> candidates;
36
37 for (auto node : loco::all_nodes(g))
38 {
39 if (active_nodes.find(node) == active_nodes.end())
40 {
41 candidates.insert(node);
42 }
43 }
44
45 // Find the nodes that should not be dead node in candidates
46 for (auto it = candidates.begin(); it != candidates.end();)
47 {
48 if (auto service = (*it)->dialect()->service<DeadNodeQueryService>())
49 {
50 if (!service->isDeadNode(*it))
51 {
52 it = candidates.erase(it);
53 continue;
54 }
55 }
56 ++it;
57 }
58
59 for (auto node : candidates)
60 {
61 node->drop();
62 }
63
64 for (auto node : candidates)
65 {
66 g->nodes()->destroy(node);
67 }
68
69 return candidates.size() > 0;
70}
std::set< Node * > all_nodes(Graph *)
Enumerate all the nodes in a given graph.
Definition Graph.cpp:59
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::all_nodes(), and loco::output_nodes().

Referenced by package.infer.session::inference().


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