Skip to main content

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 = 68

bool

bool = 1

float16

float16 = 67

float32

float32 = 69

float64

float64 = 70

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