ONE - On-device Neural Engine
Loading...
Searching...
No Matches
logo::ConstantFoldingPass Class Reference

Performs constant folding optimization. More...

#include <ConstantFoldingPass.h>

Collaboration diagram for logo::ConstantFoldingPass:

Public Member Functions

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

Detailed Description

Performs constant folding optimization.

Definition at line 30 of file ConstantFoldingPass.h.

Member Function Documentation

◆ name()

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

Reimplemented from logo::Pass.

Definition at line 33 of file ConstantFoldingPass.h.

33{ return "ConstantFoldingPass"; }

◆ run()

bool logo::ConstantFoldingPass::run ( loco::Graph graph)
overridevirtual

Run the pass.

Returns
false if there was nothing changed

Implements logo::Pass.

Definition at line 155 of file ConstantFoldingPass.cpp.

156{
157 auto outputs = loco::output_nodes(graph);
158
159 bool changed = false;
160 for (auto node : loco::postorder_traversal(outputs))
161 {
162 if (foldable(node))
163 {
164 fold(graph, node);
165 changed = true;
166 }
167 }
168
169 return changed;
170}
std::vector< loco::Node * > postorder_traversal(const std::vector< loco::Node * > &roots)
Generate postorder traversal sequence starting from "roots".
Definition Algorithm.cpp:53
std::vector< Node * > output_nodes(Graph *)
Definition Graph.cpp:101

References loco::output_nodes(), and loco::postorder_traversal().

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


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