tvm
Public Types | Public Member Functions | Static Public Member Functions | List of all members
tvm::runtime::DataType Class Reference

Runtime primitive data type. More...

#include <data_type.h>

Collaboration diagram for tvm::runtime::DataType:

Public Types

enum  TypeCode {
  kInt = kDLInt , kUInt = kDLUInt , kFloat = kDLFloat , kHandle = TVMArgTypeCode::kTVMOpaqueHandle ,
  kBFloat = kDLBfloat , kE4M3Float = 6U , kE5M2Float = 7U , kCustomBegin = 129
}
 Type code for the DataType. More...
 

Public Member Functions

 DataType ()
 default constructor More...
 
 DataType (DLDataType dtype)
 Constructor. More...
 
 DataType (int code, int bits, int lanes, bool is_scalable=false)
 Constructor. More...
 
int code () const
 
int bits () const
 
int bytes () const
 
int lanes () const
 
int vscale_factor () const
 
int get_lanes_or_vscale_factor () const
 
bool is_scalar () const
 
bool is_bool () const
 
bool is_float () const
 
bool is_float8 () const
 
bool is_e4m3_float8 () const
 
bool is_e5m2_float8 () const
 
bool is_float16 () const
 
bool is_bfloat16 () const
 
bool is_int () const
 
bool is_uint () const
 
bool is_handle () const
 
bool is_scalable_or_fixed_length_vector () const
 
bool is_fixed_length_vector () const
 
bool is_scalable_vector () const
 
bool is_vector_bool () const
 
bool is_void () const
 
DataType with_lanes (int lanes) const
 Create a new data type by change lanes to a specified value. More...
 
DataType with_scalable_vscale_factor (int vscale_factor) const
 Create a new scalable vector data type by changing the vscale multiplier to a specified value. We'll use the data_.lanes field for this value. More...
 
DataType with_bits (int bits) const
 Create a new data type by change bits to a specified value. More...
 
DataType element_of () const
 Get the scalar version of the type. More...
 
DataTypeoperator= (const DataType &rhs)
 Assignment operator. More...
 
bool operator== (const DataType &other) const
 Equal comparator. More...
 
bool operator!= (const DataType &other) const
 NotEqual comparator. More...
 
 operator DLDataType () const
 Converter to DLDataType. More...
 

Static Public Member Functions

static DataType Int (int bits, int lanes=1)
 Construct an int type. More...
 
static DataType UInt (int bits, int lanes=1, bool is_scalable=false)
 Construct an uint type. More...
 
static DataType Float (int bits, int lanes=1)
 Construct an float type. More...
 
static DataType BFloat (int bits, int lanes=1)
 Construct an bfloat type. More...
 
static DataType NVFloat8E4M3 (int lanes=1)
 Construct NV float8 e4m3 datatype. More...
 
static DataType NVFloat8E5M2 (int lanes=1)
 Construct NV float8 e5m2 datatype. More...
 
static DataType Bool (int lanes=1, bool is_scalable=false)
 Construct a bool type. More...
 
static DataType Handle (int bits=64, int lanes=1)
 Construct a handle type. More...
 
static DataType Void ()
 Construct a Void type. More...
 
static DataType ShapeIndex ()
 Get the corresponding type of TVMShapeIndex. More...
 

Detailed Description

Runtime primitive data type.

This class is a thin wrapper of DLDataType. We also make use of DataType in compiler to store quick hint

Member Enumeration Documentation

◆ TypeCode

Type code for the DataType.

DLPack consistency: 1) kInt is consistent with kDLInt 2) kUInt is consistent with kDLUInt 3) kFloat is consistent with kDLFloat

Enumerator
kInt 
kUInt 
kFloat 
kHandle 
kBFloat 
kE4M3Float 
kE5M2Float 
kCustomBegin 

Constructor & Destructor Documentation

◆ DataType() [1/3]

tvm::runtime::DataType::DataType ( )
inline

default constructor

◆ DataType() [2/3]

tvm::runtime::DataType::DataType ( DLDataType  dtype)
inlineexplicit

Constructor.

Parameters
dtypeThe DLDataType

◆ DataType() [3/3]

tvm::runtime::DataType::DataType ( int  code,
int  bits,
int  lanes,
bool  is_scalable = false 
)
inline

Constructor.

Parameters
codeThe type code.
bitsThe number of bits in the type.
lanesThe number of lanes.
is_scalableWhether the data type is scalable.

Member Function Documentation

◆ BFloat()

static DataType tvm::runtime::DataType::BFloat ( int  bits,
int  lanes = 1 
)
inlinestatic

Construct an bfloat type.

Parameters
bitsThe number of bits in the type.
lanesThe number of lanes
Returns
The constructed data type.

◆ bits()

int tvm::runtime::DataType::bits ( ) const
inline
Returns
number of bits in the data.

◆ Bool()

static DataType tvm::runtime::DataType::Bool ( int  lanes = 1,
bool  is_scalable = false 
)
inlinestatic

Construct a bool type.

Parameters
lanesThe number of lanes.
is_scalableWhether the data type is scalable.
Returns
The constructed data type.

◆ bytes()

int tvm::runtime::DataType::bytes ( ) const
inline
Returns
number of bytes to store each scalar.

◆ code()

int tvm::runtime::DataType::code ( ) const
inline
Returns
The type code.

◆ element_of()

DataType tvm::runtime::DataType::element_of ( ) const
inline

Get the scalar version of the type.

Returns
the result type.

◆ Float()

static DataType tvm::runtime::DataType::Float ( int  bits,
int  lanes = 1 
)
inlinestatic

Construct an float type.

Parameters
bitsThe number of bits in the type.
lanesThe number of lanes
Returns
The constructed data type.

◆ get_lanes_or_vscale_factor()

int tvm::runtime::DataType::get_lanes_or_vscale_factor ( ) const
inline
Returns
get vscale factor or lanes depending on scalability of the vector.

◆ Handle()

static DataType tvm::runtime::DataType::Handle ( int  bits = 64,
int  lanes = 1 
)
inlinestatic

Construct a handle type.

Parameters
bitsThe number of bits in the type.
lanesThe number of lanes
Returns
The constructed data type.

◆ Int()

static DataType tvm::runtime::DataType::Int ( int  bits,
int  lanes = 1 
)
inlinestatic

Construct an int type.

Parameters
bitsThe number of bits in the type.
lanesThe number of lanes.
Returns
The constructed data type.

◆ is_bfloat16()

bool tvm::runtime::DataType::is_bfloat16 ( ) const
inline
Returns
whether type is a bfloat16 type.

◆ is_bool()

bool tvm::runtime::DataType::is_bool ( ) const
inline
Returns
whether type is a scalar type.

◆ is_e4m3_float8()

bool tvm::runtime::DataType::is_e4m3_float8 ( ) const
inline

◆ is_e5m2_float8()

bool tvm::runtime::DataType::is_e5m2_float8 ( ) const
inline

◆ is_fixed_length_vector()

bool tvm::runtime::DataType::is_fixed_length_vector ( ) const
inline
Returns
Whether the type is a fixed length vector.

◆ is_float()

bool tvm::runtime::DataType::is_float ( ) const
inline
Returns
whether type is a float type.

◆ is_float16()

bool tvm::runtime::DataType::is_float16 ( ) const
inline
Returns
whether type is a float16 type.

◆ is_float8()

bool tvm::runtime::DataType::is_float8 ( ) const
inline
Returns
whether type is a float8 type.

◆ is_handle()

bool tvm::runtime::DataType::is_handle ( ) const
inline
Returns
whether type is a handle type.

◆ is_int()

bool tvm::runtime::DataType::is_int ( ) const
inline
Returns
whether type is an int type.

◆ is_scalable_or_fixed_length_vector()

bool tvm::runtime::DataType::is_scalable_or_fixed_length_vector ( ) const
inline
Returns
whether type is a vector type.

◆ is_scalable_vector()

bool tvm::runtime::DataType::is_scalable_vector ( ) const
inline
Returns
Whether the type is a scalable vector.

◆ is_scalar()

bool tvm::runtime::DataType::is_scalar ( ) const
inline
Returns
whether type is a scalar type.

◆ is_uint()

bool tvm::runtime::DataType::is_uint ( ) const
inline
Returns
whether type is an uint type.

◆ is_vector_bool()

bool tvm::runtime::DataType::is_vector_bool ( ) const
inline
Returns
whether type is a bool vector type.

◆ is_void()

bool tvm::runtime::DataType::is_void ( ) const
inline
Returns
whether type is a Void type.

◆ lanes()

int tvm::runtime::DataType::lanes ( ) const
inline
Returns
number of lanes in the data.

◆ NVFloat8E4M3()

static DataType tvm::runtime::DataType::NVFloat8E4M3 ( int  lanes = 1)
inlinestatic

Construct NV float8 e4m3 datatype.

Parameters
lanesThe number of lanes
Returns
The constructed data type.

◆ NVFloat8E5M2()

static DataType tvm::runtime::DataType::NVFloat8E5M2 ( int  lanes = 1)
inlinestatic

Construct NV float8 e5m2 datatype.

Parameters
lanesThe number of lanes
Returns
The constructed data type.

◆ operator DLDataType()

tvm::runtime::DataType::operator DLDataType ( ) const
inline

Converter to DLDataType.

Returns
the result.

◆ operator!=()

bool tvm::runtime::DataType::operator!= ( const DataType other) const
inline

NotEqual comparator.

Parameters
otherThe data type to compare against.
Returns
The comparison result.

◆ operator=()

DataType& tvm::runtime::DataType::operator= ( const DataType rhs)
inline

Assignment operator.

◆ operator==()

bool tvm::runtime::DataType::operator== ( const DataType other) const
inline

Equal comparator.

Parameters
otherThe data type to compare against.
Returns
The comparison result.

◆ ShapeIndex()

static DataType tvm::runtime::DataType::ShapeIndex ( )
inlinestatic

Get the corresponding type of TVMShapeIndex.

Returns
The type of TVM shape index.

◆ UInt()

static DataType tvm::runtime::DataType::UInt ( int  bits,
int  lanes = 1,
bool  is_scalable = false 
)
inlinestatic

Construct an uint type.

Parameters
bitsThe number of bits in the type.
lanesThe number of lanes.
is_scalableWhether the data type is scalable.
Returns
The constructed data type.

◆ Void()

static DataType tvm::runtime::DataType::Void ( )
inlinestatic

Construct a Void type.

Returns
The constructed data type.

◆ vscale_factor()

int tvm::runtime::DataType::vscale_factor ( ) const
inline
Returns
the integer multiplier of vscale in a scalable vector.

◆ with_bits()

DataType tvm::runtime::DataType::with_bits ( int  bits) const
inline

Create a new data type by change bits to a specified value.

Parameters
bitsThe target number of bits.
Returns
the result type.

◆ with_lanes()

DataType tvm::runtime::DataType::with_lanes ( int  lanes) const
inline

Create a new data type by change lanes to a specified value.

Parameters
lanesThe target number of lanes.
Returns
the result type.

◆ with_scalable_vscale_factor()

DataType tvm::runtime::DataType::with_scalable_vscale_factor ( int  vscale_factor) const
inline

Create a new scalable vector data type by changing the vscale multiplier to a specified value. We'll use the data_.lanes field for this value.

Parameters
vscale_factorThe vscale multiplier.
Returns
A copy of the old DataType with the number of scalable lanes.

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