Skip to main content
Log in

Python module

dtype

DType

class max.dtype.DType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

The tensor data type.

align

property align*: int*

Returns the alignment of the dtype.

bfloat16

bfloat16 = 70

bool

bool = 1

f8e4m3

f8e4m3 = 65

f8e4m3fnuz

f8e4m3fnuz = 68

f8e5m2

f8e5m2 = 64

f8e5m2fnuz

f8e5m2fnuz = 67

float16

float16 = 69

float32

float32 = 71

float64

float64 = 72

from_numpy()

classmethod from_numpy(dtype: dtype) → DType

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

int32

int32 = 139

int64

int64 = 141

int8

int8 = 135

is_float()

is_float() → 1

Returns true if the dtype is floating point.

size_in_bytes

property size_in_bytes*: int*

Returns the size of the dtype in bytes.

to_numpy()

to_numpy() → dtype

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.

uint16

uint16 = 136

uint32

uint32 = 138

uint64

uint64 = 140

uint8

uint8 = 134