ONE - On-device Neural Engine
Loading...
Searching...
No Matches
loco::TypeInferenceSession Class Reference

#include <TypeInference.h>

Public Member Functions

 TypeInferenceSession (const TypeInferenceRule *rule)
 
bool to (Graph *g) const
 

Detailed Description

Definition at line 84 of file TypeInference.h.

Constructor & Destructor Documentation

◆ TypeInferenceSession()

loco::TypeInferenceSession::TypeInferenceSession ( const TypeInferenceRule rule)
inline

Definition at line 87 of file TypeInference.h.

87 : _rule{rule}
88 {
89 // DO NOTHING
90 }

Member Function Documentation

◆ to()

bool loco::TypeInferenceSession::to ( Graph g) const

Definition at line 61 of file TypeInference.cpp.

62{
63 bool changed = false;
64
65 for (auto node : postorder_traversal(output_nodes(g)))
66 {
67 if (_rule->recognize(node->dialect()))
68 {
69 DataType dtype = DataType::Unknown;
70
71 if (!dtype_known(node) && inputs_dtype_ready(node))
72 {
73 if (_rule->infer(node, dtype))
74 {
75 node->annot(std::make_unique<DataTypeAnnotation>(dtype));
76 changed = true;
77 }
78 }
79 }
80 }
81
82 return changed;
83}
std::vector< loco::Node * > postorder_traversal(const std::vector< loco::Node * > &roots)
Generate postorder traversal sequence starting from "roots".
Definition Algorithm.cpp:53
std::vector< Node * > output_nodes(Graph *)
Definition Graph.cpp:101
bool dtype_known(const Node *node)
DataType
"scalar" value type
Definition DataType.h:27
virtual bool recognize(const Dialect *) const =0
Return true if this rule recognizes a given dialect.
virtual bool infer(const Node *, DataType &) const =0

References loco::AnnotatedItem< Annotation >::annot(), loco::Node::dialect(), loco::dtype_known(), loco::TypeInferenceRule::infer(), loco::output_nodes(), loco::postorder_traversal(), and loco::TypeInferenceRule::recognize().


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