ONE - On-device Neural Engine
Loading...
Searching...
No Matches
luci::CircleShapeInferencePass Class Reference

Pass to infer shape of circle nodes. More...

#include <CircleShapeInferencePass.h>

Collaboration diagram for luci::CircleShapeInferencePass:

Public Member Functions

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

Detailed Description

Pass to infer shape of circle nodes.

Definition at line 30 of file CircleShapeInferencePass.h.

Member Function Documentation

◆ name()

virtual const char * luci::CircleShapeInferencePass::name ( void  ) const
inlinevirtual

Reimplemented from logo::Pass.

Definition at line 33 of file CircleShapeInferencePass.h.

33{ return "luci::CircleShapeInferencePass"; }

◆ run() [1/2]

bool luci::CircleShapeInferencePass::run ( loco::Graph graph)
virtual

Run the pass.

Returns
false if there was nothing changed

Implements logo::Pass.

Definition at line 42 of file CircleShapeInferencePass.cpp.

43{
44 luci::sinf::Rule shape_infer_rule;
45 bool changed = false;
46
47 for (auto node : inference_candidates(g))
48 {
50 auto circle_node = loco::must_cast<luci::CircleNode *>(node);
51
52 if (shape_infer_rule.infer(circle_node, shape) && !is_same_shape(circle_node, shape))
53 {
54 circle_node->rank(shape.rank());
55 for (uint32_t i = 0; i < shape.rank(); ++i)
56 circle_node->dim(i) = shape.dim(i);
57
58 circle_node->shape_status(luci::ShapeStatus::VALID);
59
60 changed = true;
61 }
62 }
63
64 return changed;
65}
const Dimension & dim(uint32_t axis) const
Definition TensorShape.h:38
uint32_t rank(void) const
Definition TensorShape.h:35
bool is_same_shape(const luci::CircleNode *node, const loco::TensorShape &shape)
Definition Shape.cpp:22
std::vector< loco::Node * > inference_candidates(loco::Graph *g)
Enumerate all the nodes whose shape/dtype should be inferenced to export graph.
bool infer(const luci::CircleNode *, loco::TensorShape &) const

References loco::TensorShape::dim(), luci::sinf::Rule::infer(), luci::inference_candidates(), luci::is_same_shape(), loco::TensorShape::rank(), and luci::VALID.

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

◆ run() [2/2]

bool luci::CircleShapeInferencePass::run ( luci::Module m)
virtual

Implements luci::Pass.

Definition at line 29 of file CircleShapeInferencePass.cpp.

30{
31 bool changed = false;
32
33 for (size_t g = 0; g < m->size(); ++g)
34 {
35 if (run(m->graph(g)))
36 changed = true;
37 }
38
39 return changed;
40}

References m, and run().

Referenced by package.infer.session::inference(), and run().


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