ONE - On-device Neural Engine
Loading...
Searching...
No Matches
luci::FoldShapePass Struct Referencefinal

Class to fold Shape to a constant tensor. More...

#include <FoldShapePass.h>

Collaboration diagram for luci::FoldShapePass:

Public Member Functions

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

Detailed Description

Class to fold Shape to a constant tensor.

Definition at line 28 of file FoldShapePass.h.

Member Function Documentation

◆ name()

const char * luci::FoldShapePass::name ( void  ) const
inlinefinalvirtual

Reimplemented from logo::Pass.

Definition at line 30 of file FoldShapePass.h.

30{ return "luci::FoldShapePass"; }

◆ run()

bool luci::FoldShapePass::run ( loco::Graph g)
finalvirtual

BEFORE

[CircleNode]
      |
[CircleShape]
      |
[CircleNode]

AFTER

[CircleConst]  [CircleNode]
      |
[CircleNode]

Implements logo::Pass.

Definition at line 91 of file FoldShapePass.cpp.

92{
93 bool changed = false;
94 for (auto node : loco::active_nodes(loco::output_nodes(g)))
95 {
96 if (auto shape = dynamic_cast<luci::CircleShape *>(node))
97 {
98 auto out_type = shape->out_type();
99 switch (out_type)
100 {
101 case loco::DataType::S32:
102 if (fold_shape<loco::DataType::S32>(shape))
103 changed = true;
104 break;
105 case loco::DataType::S64:
106 if (fold_shape<loco::DataType::S64>(shape))
107 changed = true;
108 break;
109 default:
110 break;
111 }
112 }
113 }
114
115 return changed;
116}
SHAPE in Circle.
Definition CircleShape.h:32
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(), luci::CircleShape::out_type(), and loco::output_nodes().

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


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