MLIR  20.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 39 of file InferTypeOpInterface.h.

Constructor & Destructor Documentation

◆ ShapeAdaptor() [1/4]

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

Definition at line 41 of file InferTypeOpInterface.h.

◆ ShapeAdaptor() [2/4]

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

Definition at line 45 of file InferTypeOpInterface.h.

◆ ShapeAdaptor() [3/4]

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

Definition at line 49 of file InferTypeOpInterface.h.

◆ ShapeAdaptor() [4/4]

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

Definition at line 50 of file InferTypeOpInterface.h.

Member Function Documentation

◆ dump()

void ShapeAdaptor::dump ( ) const

Dumps textual repesentation to stderr.

Definition at line 174 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 105 of file InferTypeOpInterface.cpp.

References getDims(), and hasRank().

◆ getDims() [2/2]

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

Populates the dimensions from shape referenced.

Requires: shape is ranked.

Definition at line 88 of file InferTypeOpInterface.cpp.

References hasRank().

Referenced by dump(), getDims(), 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 111 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 78 of file InferTypeOpInterface.cpp.

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

◆ getNumElements()

int64_t ShapeAdaptor::getNumElements ( ) const

Returns the number of elements in the shape.

Requires: hasStaticShape

Definition at line 149 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 123 of file InferTypeOpInterface.cpp.

References getDims(), and hasRank().

Referenced by dump(), and ReduceInferReturnTypes().

◆ hasRank()

bool ShapeAdaptor::hasRank ( ) const

◆ hasStaticShape()

bool ShapeAdaptor::hasStaticShape ( ) const

Returns whether the shape is fully static.

Definition at line 132 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 72 of file InferTypeOpInterface.h.

References getDimSize().

◆ operator bool()

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

Returns whether valid (non-null) shape.

Definition at line 88 of file InferTypeOpInterface.h.


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