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

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

#include <ConstantFoldStridedSlice.h>

Collaboration diagram for moco::ConstantFoldStridedSlice:

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

Definition at line 30 of file ConstantFoldStridedSlice.h.

Member Function Documentation

◆ name()

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

Reimplemented from logo::Pass.

Definition at line 33 of file ConstantFoldStridedSlice.h.

33{ return "ConstantFoldStridedSlice"; }

◆ run()

bool moco::ConstantFoldStridedSlice::run ( loco::Graph graph)
overridevirtual
Note
This will Replace TFStridedSlice with TFConst when 'input' is TFConst
  Before
            A --- TFStridedSlice --- C
            B --/
  After
            A --- TFStridedSlice
            B --/
                  TFConst ---------- C
  Where
            A,B : inputs of TFStridedSlice
            C : a node that uses TFStridedSlice as an input
            TFStridedSlice is disconnected from C
            Nodes are drawn multiple times to simplify the diagram
  Limits
            Only limit set of inputs are supported for now

Implements logo::Pass.

Definition at line 276 of file ConstantFoldStridedSlice.cpp.

277{
278 bool changed = false;
279 for (auto node : loco::active_nodes(loco::output_nodes(graph)))
280 {
281 if (auto sslice_node = as<moco::TFStridedSlice>(node))
282 {
283 if (constantfold_stridedslice(sslice_node))
284 changed = true;
285 }
286 }
287
288 return changed;
289}
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: