ONE - On-device Neural Engine
Loading...
Searching...
No Matches
loco::CanonicalTypeInferenceRule Struct Referencefinal

Type Inference Rule for Canonical Dialect. More...

#include <TypeInference.h>

Collaboration diagram for loco::CanonicalTypeInferenceRule:

Public Member Functions

bool recognize (const Dialect *) const final
 Return true if this rule recognizes a given dialect.
 
bool infer (const Node *, DataType &) const final
 
- Public Member Functions inherited from loco::TypeInferenceRule
virtual ~TypeInferenceRule ()=default
 

Detailed Description

Type Inference Rule for Canonical Dialect.

Definition at line 62 of file TypeInference.h.

Member Function Documentation

◆ infer()

bool loco::CanonicalTypeInferenceRule::infer ( const Node ,
DataType  
) const
finalvirtual

Framework guarantees the followings:

  1. Framework tries to infer the data type of each node only after the data type of all of its valid (= non-nullptr) argument nodes is inferred.
  2. The result of preceding "infer" is accessible through below dtype_get method.
    • This holds only when preceding "infer" returns true.

Implements loco::TypeInferenceRule.

Definition at line 178 of file TypeInference.cpp.

179{
180 assert(node->dialect() == loco::CanonicalDialect::get());
181 assert(dynamic_cast<const loco::CanonicalNode *>(node) != nullptr);
182
183 CanonicalTypeForwardAlgorithm alg;
184 dtype = loco::must_cast<const loco::CanonicalNode *>(node)->accept(&alg);
185
186 return true;
187}
static Dialect * get(void)

References loco::Node::dialect(), and loco::CanonicalDialect::get().

◆ recognize()

bool loco::CanonicalTypeInferenceRule::recognize ( const Dialect ) const
finalvirtual

Return true if this rule recognizes a given dialect.

Implements loco::TypeInferenceRule.

Definition at line 172 of file TypeInference.cpp.

173{
174 // This rule recognizes only "loco.canonical" dialect!
175 return CanonicalDialect::get() == d;
176}

References loco::CanonicalDialect::get().


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