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 = kDLOpaqueHandle ,
  kBFloat = kDLBfloat , kFloat8_e3m4 = kDLFloat8_e3m4 , kFloat8_e4m3 = kDLFloat8_e4m3 , kFloat8_e4m3b11fnuz = kDLFloat8_e4m3b11fnuz ,
  kFloat8_e4m3fn = kDLFloat8_e4m3fn , kFloat8_e4m3fnuz = kDLFloat8_e4m3fnuz , kFloat8_e5m2 = kDLFloat8_e5m2 , kFloat8_e5m2fnuz = kDLFloat8_e5m2fnuz ,
  kFloat8_e8m0fnu = kDLFloat8_e8m0fnu , kFloat6_e2m3fn = kDLFloat6_e2m3fn , kFloat6_e3m2fn = kDLFloat6_e3m2fn , kFloat4_e2m1fn = kDLFloat4_e2m1fn ,
  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_bfloat () const
 
bool is_float8 () const
 
bool is_float6 () const
 
bool is_float4 () const
 
bool is_float8_e3m4 () const
 
bool is_float8_e4m3 () const
 
bool is_float8_e4m3b11fnuz () const
 
bool is_float8_e4m3fn () const
 
bool is_float8_e4m3fnuz () const
 
bool is_float8_e5m2 () const
 
bool is_float8_e5m2fnuz () const
 
bool is_float8_e8m0fnu () const
 
bool is_float6_e2m3fn () const
 
bool is_float6_e3m2fn () const
 
bool is_float4_e2m1fn () 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 () 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 Float8E3M4 (int lanes=1)
 Construct float8 e3m4 datatype. More...
 
static DataType Float8E4M3 (int lanes=1)
 Construct float8 e4m3 datatype. More...
 
static DataType Float8E4M3B11FNUZ (int lanes=1)
 Construct float8 e4m3b11fnuz datatype. More...
 
static DataType Float8E4M3FN (int lanes=1)
 Construct float8 e4m3fn datatype. More...
 
static DataType Float8E4M3FNUZ (int lanes=1)
 Construct float8 e4m3fnuz datatype. More...
 
static DataType Float8E5M2 (int lanes=1)
 Construct float8 e5m2 datatype. More...
 
static DataType Float8E5M2FNUZ (int lanes=1)
 Construct float8 e5m2fnuz datatype. More...
 
static DataType Float8E8M0FNU (int lanes=1)
 Construct float8 e8m0fnu datatype. More...
 
static DataType Float6E2M3FN (int lanes=1)
 Construct float6 e2m3fn datatype. More...
 
static DataType Float6E3M2FN (int lanes=1)
 Construct float6 e3m2fn datatype. More...
 
static DataType Float4E2M1FN (int lanes=1)
 Construct float4 e2m1fn 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 
kFloat8_e3m4 
kFloat8_e4m3 
kFloat8_e4m3b11fnuz 
kFloat8_e4m3fn 
kFloat8_e4m3fnuz 
kFloat8_e5m2 
kFloat8_e5m2fnuz 
kFloat8_e8m0fnu 
kFloat6_e2m3fn 
kFloat6_e3m2fn 
kFloat4_e2m1fn 
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.

◆ Float4E2M1FN()

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

Construct float4 e2m1fn datatype.

Parameters
lanesThe number of lanes
Returns
The constructed data type.

◆ Float6E2M3FN()

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

Construct float6 e2m3fn datatype.

Parameters
lanesThe number of lanes
Returns
The constructed data type.

◆ Float6E3M2FN()

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

Construct float6 e3m2fn datatype.

Parameters
lanesThe number of lanes
Returns
The constructed data type.

◆ Float8E3M4()

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

Construct float8 e3m4 datatype.

Parameters
lanesThe number of lanes
Returns
The constructed data type.

◆ Float8E4M3()

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

Construct float8 e4m3 datatype.

Parameters
lanesThe number of lanes
Returns
The constructed data type.

◆ Float8E4M3B11FNUZ()

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

Construct float8 e4m3b11fnuz datatype.

Parameters
lanesThe number of lanes
Returns
The constructed data type.

◆ Float8E4M3FN()

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

Construct float8 e4m3fn datatype.

Parameters
lanesThe number of lanes
Returns
The constructed data type.

◆ Float8E4M3FNUZ()

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

Construct float8 e4m3fnuz datatype.

Parameters
lanesThe number of lanes
Returns
The constructed data type.

◆ Float8E5M2()

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

Construct float8 e5m2 datatype.

Parameters
lanesThe number of lanes
Returns
The constructed data type.

◆ Float8E5M2FNUZ()

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

Construct float8 e5m2fnuz datatype.

Parameters
lanesThe number of lanes
Returns
The constructed data type.

◆ Float8E8M0FNU()

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

Construct float8 e8m0fnu datatype.

Parameters
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_bfloat()

bool tvm::runtime::DataType::is_bfloat ( ) const
inline
Returns
whether type is a bfloat 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_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_float4()

bool tvm::runtime::DataType::is_float4 ( ) const
inline
Returns
whether type is the 4-bit custom Float4_e2m1fn variant.

◆ is_float4_e2m1fn()

bool tvm::runtime::DataType::is_float4_e2m1fn ( ) const
inline
Returns
whether type is Float4E2M1FN.

◆ is_float6()

bool tvm::runtime::DataType::is_float6 ( ) const
inline
Returns
whether type is any 6-bit custom Float6 variant.

◆ is_float6_e2m3fn()

bool tvm::runtime::DataType::is_float6_e2m3fn ( ) const
inline
Returns
whether type is Float6E2M3FN.

◆ is_float6_e3m2fn()

bool tvm::runtime::DataType::is_float6_e3m2fn ( ) const
inline
Returns
whether type is Float6E3M2FN.

◆ is_float8()

bool tvm::runtime::DataType::is_float8 ( ) const
inline
Returns
whether type is any 8-bit custom Float8 variant.

◆ is_float8_e3m4()

bool tvm::runtime::DataType::is_float8_e3m4 ( ) const
inline
Returns
whether type is Float8E3M4.

◆ is_float8_e4m3()

bool tvm::runtime::DataType::is_float8_e4m3 ( ) const
inline
Returns
whether type is Float8E4M3.

◆ is_float8_e4m3b11fnuz()

bool tvm::runtime::DataType::is_float8_e4m3b11fnuz ( ) const
inline
Returns
whether type is Float8E4M3B11FNUZ.

◆ is_float8_e4m3fn()

bool tvm::runtime::DataType::is_float8_e4m3fn ( ) const
inline
Returns
whether type is Float8E4M3FN.

◆ is_float8_e4m3fnuz()

bool tvm::runtime::DataType::is_float8_e4m3fnuz ( ) const
inline
Returns
whether type is Float8E4M3FNUZ.

◆ is_float8_e5m2()

bool tvm::runtime::DataType::is_float8_e5m2 ( ) const
inline
Returns
whether type is Float8E5M2.

◆ is_float8_e5m2fnuz()

bool tvm::runtime::DataType::is_float8_e5m2fnuz ( ) const
inline
Returns
whether type is Float8E5M2FNUZ.

◆ is_float8_e8m0fnu()

bool tvm::runtime::DataType::is_float8_e8m0fnu ( ) const
inline
Returns
whether type is Float8E8M0FNU.

◆ 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 tvm::runtime::DataType::is_vector ( ) const
inline
Returns
whether type is a vector 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.

◆ 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: