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

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

#include <ConstantFoldPack.h>

Collaboration diagram for moco::ConstantFoldPack:

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 + Pack -> Const.

Definition at line 32 of file ConstantFoldPack.h.

Member Function Documentation

◆ name()

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

Reimplemented from logo::Pass.

Definition at line 35 of file ConstantFoldPack.h.

35{ return "ConstantFoldPack"; }

◆ run()

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

Implements logo::Pass.

Definition at line 165 of file ConstantFoldPack.cpp.

166{
167 bool changed = false;
168 for (auto node : loco::active_nodes(loco::output_nodes(graph)))
169 {
170 if (auto pack_node = as<moco::TFPack>(node))
171 {
172 if (constantfold_pack(pack_node))
173 changed = true;
174 }
175 }
176
177 return changed;
178}
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: