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

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

#include <CircleTypeInferencePass.h>

Collaboration diagram for luci::CircleTypeInferencePass:

Public Member Functions

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

Detailed Description

Pass to infer type of circle nodes.

Definition at line 30 of file CircleTypeInferencePass.h.

Member Function Documentation

◆ name()

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

Reimplemented from logo::Pass.

Definition at line 33 of file CircleTypeInferencePass.h.

33{ return "luci::CircleTypeInferencePass"; }

◆ run() [1/2]

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

Run the pass.

Returns
false if there was nothing changed

Implements logo::Pass.

Definition at line 41 of file CircleTypeInferencePass.cpp.

42{
43 luci::tinf::Rule type_infer_rule;
44 bool changed = false;
45
46 for (auto node : inference_candidates(g))
47 {
49 auto circle_node = loco::must_cast<luci::CircleNode *>(node);
50
51 if (type_infer_rule.infer(circle_node, dtype) && circle_node->dtype() != dtype)
52 {
53 circle_node->dtype(dtype);
54 changed = true;
55 }
56 }
57
58 return changed;
59}
DataType
"scalar" value type
Definition DataType.h:27
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::DataType &) const

References luci::tinf::Rule::infer(), and luci::inference_candidates().

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

◆ run() [2/2]

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

Implements luci::Pass.

Definition at line 28 of file CircleTypeInferencePass.cpp.

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

References m, and run().

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


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