Skip to main content
Log in

Python module

dtype

DType

class max.dtype.DType(value, names=<not given>, *values, 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 = 71

bool

bool = 1

float16

float16 = 70

float32

float32 = 72

float64

float64 = 73

float8_e4m3

float8_e4m3 = 65

float8_e4m3fn

float8_e4m3fn = 66

float8_e4m3fnuz

float8_e4m3fnuz = 67

float8_e5m2

float8_e5m2 = 68

float8_e5m2fnuz

float8_e5m2fnuz = 69

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() → __builtins__.bool

Returns true if the dtype is floating point.

is_integral()

is_integral() → __builtins__.bool

Returns true if the dtype is an integer.

size_in_bytes

property size_in_bytes*: int*

Returns the size of the dtype in bytes.

to_numpy()

to_numpy() → dtype

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.

uint16

uint16 = 136

uint32

uint32 = 138

uint64

uint64 = 140

uint8

uint8 = 134