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

#include <CircleShapeInferenceRule.h>

Collaboration diagram for luci::CircleShapeInferenceRule:

Public Member Functions

bool recognize (const loco::Dialect *) const final
 Return true if this rule recognizes a given dialect.
 
bool infer (const loco::Node *, loco::NodeShape &) const final
 Infer node's shape.
 
- Public Member Functions inherited from loco::ShapeInferenceRule
virtual ~ShapeInferenceRule ()=default
 
virtual bool support (const API &api) const
 Check whether a given API is available or not.
 
virtual void infer (const Context *, const Node *, Sink *) const
 

Additional Inherited Members

- Public Types inherited from loco::ShapeInferenceRule
enum class  API { V1 , V2 }
 

Detailed Description

Definition at line 25 of file CircleShapeInferenceRule.h.

Member Function Documentation

◆ infer()

bool luci::CircleShapeInferenceRule::infer ( const loco::Node ,
loco::NodeShape  
) const
finalvirtual

Infer node's shape.

WARNING!!

Implementation SHOULD return true only when it succeeds in inference!

Implements loco::ShapeInferenceRule.

Definition at line 2265 of file CircleShapeInferenceRule.cpp.

2266{
2267 LOGGER(l);
2268
2269 assert(node->dialect() == CircleDialect::get());
2270
2271 ShapeInferenceAlgorithm alg;
2272 auto circle_node = loco::must_cast<const CircleNode *>(node);
2273
2274 bool is_shape_undefined = (circle_node->shape_status() == ShapeStatus::UNDEFINED);
2275 bool is_shape_none = (circle_node->shape_status() == ShapeStatus::NOSHAPE);
2276 bool is_scalar = (circle_node->rank() == 0);
2277
2278 if (is_shape_undefined)
2279 shape = circle_node->accept(&alg);
2280 else
2281 {
2282 if (is_shape_none || is_scalar)
2283 shape = own_shape(circle_node);
2284 else
2285 shape = circle_node->accept(&alg);
2286 }
2287
2288 VERBOSE(l, 1) << "[luci] shape: " << circle_node->name();
2289 VERBOSE(l, 1) << " own_shape: " << own_shape(circle_node)
2290 << " -> infer: " << shape.as<loco::TensorShape>();
2291
2292 return true;
2293}
#define LOGGER(name)
Definition Log.h:65
static loco::Dialect * get(void)
#define VERBOSE(name, lv)
Definition Log.h:71

References loco::NodeShape::as(), loco::Node::dialect(), luci::CircleDialect::get(), LOGGER, luci::NOSHAPE, luci::UNDEFINED, and VERBOSE.

Referenced by luci::sinf::Algorithm::visit().

◆ recognize()

bool luci::CircleShapeInferenceRule::recognize ( const loco::Dialect ) const
finalvirtual

Return true if this rule recognizes a given dialect.

Implements loco::ShapeInferenceRule.

Definition at line 2260 of file CircleShapeInferenceRule.cpp.

2261{
2262 return CircleDialect::get() == d;
2263}

References luci::CircleDialect::get().


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