ONE - On-device Neural Engine
Loading...
Searching...
No Matches
moco::ConstantFoldMul Class Reference

Constant folder for Const + Mul -> Const. More...

#include <ConstantFoldMul.h>

Collaboration diagram for moco::ConstantFoldMul:

Public Member Functions

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

Detailed Description

Constant folder for Const + Mul -> Const.

Definition at line 30 of file ConstantFoldMul.h.

Member Function Documentation

◆ name()

const char * moco::ConstantFoldMul::name ( void  ) const
inlinefinalvirtual

Reimplemented from logo::Pass.

Definition at line 33 of file ConstantFoldMul.h.

33{ return "ConstantFoldMul"; }

◆ run()

bool moco::ConstantFoldMul::run ( loco::Graph graph)
overridevirtual
Note
This will Replace TFMul with TFConst when input are TFConst
  Before
            A --- TFMul --- C
            B --/
  After
            A --- TFMul
            B --/
                  TFConst ---------- C
  Where
            A,B : inputs of TFMul
            C : a node that uses TFMul as an input
            TFMul is disconnected from C
            Nodes are drawn multiple times to simplify the diagram

Implements logo::Pass.

Definition at line 101 of file ConstantFoldMul.cpp.

102{
103 bool changed = false;
104 for (auto node : loco::active_nodes(loco::output_nodes(graph)))
105 {
106 if (auto mul_node = as<moco::TFMul>(node))
107 {
108 if (constantfold_mul(mul_node))
109 changed = true;
110 }
111 }
112
113 return changed;
114}
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(), and loco::output_nodes().

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


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