Skip to main content

Python class

DType

DType

class max.dtype.DType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)

source

Bases: Enum

The tensor data type.

align

property align

source

Returns the alignment requirement of the data type in bytes.

The alignment specifies the memory boundary that values of this data type must be aligned to for optimal performance and correctness.

bfloat16

bfloat16 = 80

source

bool

bool = 1

source

float16

float16 = 79

source

float32

float32 = 81

source

float4_e2m1fn

float4_e2m1fn = 64

source

float64

float64 = 82

source

float8_e4m3fn

float8_e4m3fn = 75

source

float8_e4m3fnuz

float8_e4m3fnuz = 76

source

float8_e5m2

float8_e5m2 = 77

source

float8_e5m2fnuz

float8_e5m2fnuz = 78

source

float8_e8m0fnu

float8_e8m0fnu = 73

source

from_numpy()

from_numpy()

source

Converts a NumPy dtype to the corresponding DType.

Parameters:

dtype (np.dtype) – The NumPy dtype to convert.

Returns:

The corresponding DType enum value.

Return type:

DType

Raises:

ValueError – If the input dtype is not supported.

int16

int16 = 137

source

int32

int32 = 139

source

int64

int64 = 141

source

int8

int8 = 135

source

is_float()

is_float(self) → bool

source

Checks if the data type is a floating-point type.

is_float8()

is_float8(self) → bool

source

Checks if the data type is an 8-bit floating-point type.

is_half()

is_half(self) → bool

source

Checks if the data type is a half-precision floating-point type.

is_integral()

is_integral(self) → bool

source

Checks if the data type is an integer type.

is_signed_integral()

is_signed_integral(self) → bool

source

Checks if the data type is a signed integer type.

is_unsigned_integral()

is_unsigned_integral(self) → bool

source

Checks if the data type is an unsigned integer type.

size_in_bits

property size_in_bits

source

Returns the size of the data type in bits.

This indicates how many bits are required to store a single value of this data type in memory.

size_in_bytes

property size_in_bytes

source

Returns the size of the data type in bytes.

This indicates how many bytes are required to store a single value of this data type in memory.

to_numpy()

to_numpy()

source

Converts this DType to the corresponding NumPy dtype.

Returns:

The corresponding NumPy dtype object.

Return type:

DType

Raises:

ValueError – If the dtype is not supported.

Parameters:

self (DType)

uint16

uint16 = 136

source

uint32

uint32 = 138

source

uint64

uint64 = 140

source

uint8

uint8 = 134

source