My Project
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
mlir::ShapedType Class Reference

#include <StandardTypes.h>

Inheritance diagram for mlir::ShapedType:
Inheritance graph
[legend]
Collaboration diagram for mlir::ShapedType:
Collaboration graph
[legend]

Public Types

using ImplType = detail::ShapedTypeStorage
 
- Public Types inherited from mlir::Type
enum  Kind {
  Function, Opaque, LAST_BUILTIN_TYPE = Opaque, DEFINE_SYM_KIND_RANGE,
  DEFINE_SYM_KIND_RANGE
}
 
template<typename ConcreteType , typename BaseType , typename StorageType = DefaultTypeStorage>
using TypeBase = detail::StorageUserBase< ConcreteType, BaseType, StorageType, detail::TypeUniquer >
 Utility class for implementing types. More...
 
using ImplType = TypeStorage
 

Public Member Functions

Type getElementType () const
 Return the element type. More...
 
unsigned getElementTypeBitWidth () const
 
int64_t getNumElements () const
 If it has static shape, return the number of elements. Otherwise, abort. More...
 
int64_t getRank () const
 If this is a ranked type, return the rank. Otherwise, abort. More...
 
bool hasRank () const
 
ArrayRef< int64_t > getShape () const
 If this is a ranked type, return the shape. Otherwise, abort. More...
 
bool hasStaticShape () const
 
bool hasStaticShape (ArrayRef< int64_t > shape) const
 If this has a static shape and the shape is equal to shape return true. More...
 
int64_t getNumDynamicDims () const
 
int64_t getDimSize (int64_t i) const
 
unsigned getDynamicDimIndex (unsigned index) const
 
int64_t getSizeInBits () const
 
- Public Member Functions inherited from mlir::Type
 Type ()
 
 Type (const ImplType *impl)
 
 Type (const Type &other)=default
 
Typeoperator= (const Type &other)=default
 
bool operator== (Type other) const
 
bool operator!= (Type other) const
 
 operator bool () const
 
bool operator! () const
 
template<typename U >
bool isa () const
 
template<typename U >
dyn_cast () const
 
template<typename U >
dyn_cast_or_null () const
 
template<typename U >
cast () const
 
unsigned getKind () const
 Return the classification for this type. More...
 
MLIRContextgetContext () const
 Return the LLVMContext in which this type was uniqued. More...
 
DialectgetDialect () const
 Get the dialect this type is registered to. More...
 
bool isIndex ()
 
bool isBF16 ()
 
bool isF16 ()
 
bool isF32 ()
 
bool isF64 ()
 
bool isInteger (unsigned width)
 Return true if this is an integer type with the specified width. More...
 
unsigned getIntOrFloatBitWidth ()
 
bool isIntOrIndex ()
 Return true if this is an integer or index type. More...
 
bool isIntOrIndexOrFloat ()
 Return true if this is an integer, index, or float type. More...
 
bool isIntOrFloat ()
 Return true of this is an integer or a float type. More...
 
void print (raw_ostream &os)
 Print the current type. More...
 
void dump ()
 
unsigned getSubclassData () const
 
void setSubclassData (unsigned val)
 
const void * getAsOpaquePointer () const
 Methods for supporting PointerLikeTypeTraits. More...
 

Static Public Member Functions

static bool classof (Type type)
 Methods for support type inquiry through isa, cast, and dyn_cast. More...
 
static constexpr bool isDynamic (int64_t dSize)
 Whether the given dimension size indicates a dynamic dimension. More...
 
static constexpr bool isDynamicStrideOrOffset (int64_t dStrideOrOffset)
 
- Static Public Member Functions inherited from mlir::Type
static bool classof (Type)
 
static Type getFromOpaquePointer (const void *pointer)
 

Static Public Attributes

static constexpr int64_t kDynamicSize = -1
 
static constexpr int64_t kDynamicStrideOrOffset
 

Additional Inherited Members

- Protected Attributes inherited from mlir::Type
ImplTypeimpl
 

Detailed Description

This is a common base class between Vector, UnrankedTensor, RankedTensor, and MemRef types because they share behavior and semantics around shape, rank, and fixed element type. Any type with these semantics should inherit from ShapedType.

Member Typedef Documentation

◆ ImplType

Member Function Documentation

◆ classof()

static bool mlir::ShapedType::classof ( Type  type)
inlinestatic

Methods for support type inquiry through isa, cast, and dyn_cast.

◆ getDimSize()

int64_t ShapedType::getDimSize ( int64_t  i) const

If this is ranked type, return the size of the specified dimension. Otherwise, abort.

◆ getDynamicDimIndex()

unsigned ShapedType::getDynamicDimIndex ( unsigned  index) const

Returns the position of the dynamic dimension relative to just the dynamic dimensions, given its index within the shape.

◆ getElementType()

Type ShapedType::getElementType ( ) const

Return the element type.

◆ getElementTypeBitWidth()

unsigned ShapedType::getElementTypeBitWidth ( ) const

If an element type is an integer or a float, return its width. Otherwise, abort.

◆ getNumDynamicDims()

int64_t ShapedType::getNumDynamicDims ( ) const

If this is a ranked type, return the number of dimensions with dynamic size. Otherwise, abort.

◆ getNumElements()

int64_t ShapedType::getNumElements ( ) const

If it has static shape, return the number of elements. Otherwise, abort.

◆ getRank()

int64_t ShapedType::getRank ( ) const

If this is a ranked type, return the rank. Otherwise, abort.

◆ getShape()

ArrayRef< int64_t > ShapedType::getShape ( ) const

If this is a ranked type, return the shape. Otherwise, abort.

◆ getSizeInBits()

int64_t ShapedType::getSizeInBits ( ) const

Get the total amount of bits occupied by a value of this type. This does not take into account any memory layout or widening constraints, e.g. a vector<3xi57> is reported to occupy 3x57=171 bit, even though in practice it will likely be stored as in a 4xi64 vector register. Fail an assertion if the size cannot be computed statically, i.e. if the type has a dynamic shape or if its elemental type does not have a known bit width.

Get the number of bits require to store a value of the given shaped type. Compute the value recursively since tensors are allowed to have vectors as elements.

◆ hasRank()

bool ShapedType::hasRank ( ) const

Whether or not this is a ranked type. Memrefs, vectors and ranked tensors have a rank, while unranked tensors do not.

◆ hasStaticShape() [1/2]

bool ShapedType::hasStaticShape ( ) const

If this is unranked type or any dimension has unknown size (<0), it doesn't have static shape. If all dimensions have known size (>= 0), it has static shape.

◆ hasStaticShape() [2/2]

bool ShapedType::hasStaticShape ( ArrayRef< int64_t >  shape) const

If this has a static shape and the shape is equal to shape return true.

◆ isDynamic()

static constexpr bool mlir::ShapedType::isDynamic ( int64_t  dSize)
inlinestatic

Whether the given dimension size indicates a dynamic dimension.

◆ isDynamicStrideOrOffset()

static constexpr bool mlir::ShapedType::isDynamicStrideOrOffset ( int64_t  dStrideOrOffset)
inlinestatic

Member Data Documentation

◆ kDynamicSize

constexpr int64_t ShapedType::kDynamicSize = -1
static

◆ kDynamicStrideOrOffset

constexpr int64_t ShapedType::kDynamicStrideOrOffset
static
Initial value:
=
std::numeric_limits<int64_t>::min()

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