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.

bfloat16

bfloat16 = 12

bool

bool = 0

float16

float16 = 9

float32

float32 = 10

float64

float64 = 11

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

int32

int32 = 3

int64

int64 = 4

int8

int8 = 1

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

uint32

uint32 = 7

uint64

uint64 = 8

uint8

uint8 = 5