MLIR  16.0.0git
Public Member Functions | List of all members
mlir::ShapeAdaptor Class Reference

Adaptor class to abstract the differences between whether value is from a ShapedType or ShapedTypeComponents or DenseIntElementsAttribute. More...

#include "mlir/Interfaces/InferTypeOpInterface.h"

Public Member Functions

 ShapeAdaptor (Type t)
 
 ShapeAdaptor (Attribute t)
 
 ShapeAdaptor (ShapedTypeComponents *components)
 
 ShapeAdaptor (ShapedTypeComponents &components)
 
bool hasRank () const
 Returns whether the shape has a rank. More...
 
Type getElementType () const
 Returns the element type. More...
 
void getDims (SmallVectorImpl< int64_t > &res) const
 Populates the dimensions from shape referenced. More...
 
void getDims (ShapedTypeComponents &res) const
 Populates the dimensions of the ShapeTypeComponents. More...
 
int64_t getDimSize (int index) const
 Returns the size of the index'th dimension. More...
 
bool isDynamicDim (int index) const
 Returns whether the index'th dimension is dynamic. More...
 
bool hasStaticShape () const
 Returns whether the shape is fully static. More...
 
int64_t getRank () const
 Returns the rank of the shape. More...
 
int64_t getNumElements () const
 Returns the number of elements in the shape. More...
 
 operator bool () const
 Returns whether valid (non-null) shape. More...
 
void dump () const
 Dumps textual repesentation to stderr. More...
 

Detailed Description

Adaptor class to abstract the differences between whether value is from a ShapedType or ShapedTypeComponents or DenseIntElementsAttribute.

Definition at line 33 of file InferTypeOpInterface.h.

Constructor & Destructor Documentation

◆ ShapeAdaptor() [1/4]

mlir::ShapeAdaptor::ShapeAdaptor ( Type  t)
inline

Definition at line 35 of file InferTypeOpInterface.h.

References mlir::Type::dyn_cast().

◆ ShapeAdaptor() [2/4]

mlir::ShapeAdaptor::ShapeAdaptor ( Attribute  t)
inline

Definition at line 39 of file InferTypeOpInterface.h.

References mlir::Attribute::dyn_cast().

◆ ShapeAdaptor() [3/4]

mlir::ShapeAdaptor::ShapeAdaptor ( ShapedTypeComponents components)
inline

Definition at line 43 of file InferTypeOpInterface.h.

◆ ShapeAdaptor() [4/4]

mlir::ShapeAdaptor::ShapeAdaptor ( ShapedTypeComponents components)
inline

Definition at line 44 of file InferTypeOpInterface.h.

Member Function Documentation

◆ dump()

void ShapeAdaptor::dump ( ) const

Dumps textual repesentation to stderr.

Definition at line 131 of file InferTypeOpInterface.cpp.

References getDims(), getRank(), and hasRank().

◆ getDims() [1/2]

void ShapeAdaptor::getDims ( ShapedTypeComponents res) const

Populates the dimensions of the ShapeTypeComponents.

Requires: shape is ranked.

Definition at line 62 of file InferTypeOpInterface.cpp.

◆ getDims() [2/2]

void ShapeAdaptor::getDims ( SmallVectorImpl< int64_t > &  res) const

Populates the dimensions from shape referenced.

Requires: shape is ranked.

Definition at line 45 of file InferTypeOpInterface.cpp.

Referenced by dump(), getRank(), ReduceInferReturnTypes(), and mlir::ShapedTypeComponents::ShapedTypeComponents().

◆ getDimSize()

int64_t ShapeAdaptor::getDimSize ( int  index) const

Returns the size of the index'th dimension.

Requires: shape is ranked.

Definition at line 68 of file InferTypeOpInterface.cpp.

References mlir::ShapedTypeComponents::getDims(), and hasRank().

Referenced by isDynamicDim(), and poolingInferReturnTypes().

◆ getElementType()

Type ShapeAdaptor::getElementType ( ) const

Returns the element type.

Definition at line 35 of file InferTypeOpInterface.cpp.

References mlir::Type::cast().

Referenced by mlir::ShapedTypeComponents::ShapedTypeComponents().

◆ getNumElements()

int64_t ShapeAdaptor::getNumElements ( ) const

Returns the number of elements in the shape.

Requires: hasStaticShape

Definition at line 106 of file InferTypeOpInterface.cpp.

References hasStaticShape().

◆ getRank()

int64_t ShapeAdaptor::getRank ( ) const

Returns the rank of the shape.

Requires: shape is ranked.

Definition at line 80 of file InferTypeOpInterface.cpp.

References getDims(), and hasRank().

Referenced by dump().

◆ hasRank()

bool ShapeAdaptor::hasRank ( ) const

Returns whether the shape has a rank.

Definition at line 25 of file InferTypeOpInterface.cpp.

Referenced by dump(), getDimSize(), getRank(), hasStaticShape(), ReduceInferReturnTypes(), and mlir::ShapedTypeComponents::ShapedTypeComponents().

◆ hasStaticShape()

bool ShapeAdaptor::hasStaticShape ( ) const

Returns whether the shape is fully static.

Definition at line 89 of file InferTypeOpInterface.cpp.

References hasRank().

Referenced by getNumElements().

◆ isDynamicDim()

bool mlir::ShapeAdaptor::isDynamicDim ( int  index) const
inline

Returns whether the index'th dimension is dynamic.

Requires: shape is ranked.

Definition at line 66 of file InferTypeOpInterface.h.

References getDimSize().

◆ operator bool()

mlir::ShapeAdaptor::operator bool ( ) const
inlineexplicit

Returns whether valid (non-null) shape.

Definition at line 82 of file InferTypeOpInterface.h.


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