For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).
Python class
DType
DTypeβ
class max.dtype.DType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)
Bases: Enum
The tensor data type.
alignβ
property align
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
16-bit bfloat16 (Brain Float) format. 1 sign bit, 8 exponent bits, 7 mantissa bits.
boolβ
bool = 1
Boolean data type. Stores True or False values.
float16β
float16 = 79
16-bit IEEE 754 half-precision floating-point. 1 sign bit, 5 exponent bits, 10 mantissa bits.
float32β
float32 = 81
32-bit IEEE 754 single-precision floating-point. 1 sign bit, 8 exponent bits, 23 mantissa bits.
float4_e2m1fnβ
float4_e2m1fn = 64
4-bit floating-point with 2 exponent bits and 1 mantissa bits, finite values only.
float64β
float64 = 82
64-bit IEEE 754 double-precision floating-point. 1 sign bit, 11 exponent bits, 52 mantissa bits.
float8_e4m3fnβ
float8_e4m3fn = 75
8-bit floating-point with 4 exponent bits and 3 mantissa bits, finite values only.
float8_e4m3fnuzβ
float8_e4m3fnuz = 76
8-bit floating-point with 4 exponent bits and 3 mantissa bits, finite values only, no negative zero.
float8_e5m2β
float8_e5m2 = 77
8-bit floating-point with 5 exponent bits and 2 mantissa bits.
float8_e5m2fnuzβ
float8_e5m2fnuz = 78
8-bit floating-point with 5 exponent bits and 2 mantissa bits, finite values only, no negative zero.
float8_e8m0fnuβ
float8_e8m0fnu = 73
8-bit floating-point with 8 exponent bits and 0 mantissa bits, finite values only.
from_numpy()β
from_numpy()
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:
-
Raises:
-
ValueError β If the input dtype is not supported.
int16β
int16 = 137
16-bit signed integer, range -32,768 to 32,767.
int32β
int32 = 139
32-bit signed integer, range -2,147,483,648 to 2,147,483,647.
int64β
int64 = 141
64-bit signed integer, range -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.
int8β
int8 = 135
8-bit signed integer, range -128 to 127.
is_float()β
is_float(self) β bool
Checks if the data type is a floating-point type.
is_float8()β
is_float8(self) β bool
Checks if the data type is an 8-bit floating-point type.
is_half()β
is_half(self) β bool
Checks if the data type is a half-precision floating-point type.
is_integral()β
is_integral(self) β bool
Checks if the data type is an integer type.
is_signed_integral()β
is_signed_integral(self) β bool
Checks if the data type is a signed integer type.
is_unsigned_integral()β
is_unsigned_integral(self) β bool
Checks if the data type is an unsigned integer type.
size_in_bitsβ
property size_in_bits
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
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()
Converts this DType to the corresponding NumPy dtype.
-
Returns:
-
The corresponding NumPy dtype object.
-
Return type:
-
Raises:
-
ValueError β If the dtype is not supported.
-
Parameters:
-
self (DType)
uint16β
uint16 = 136
16-bit unsigned integer, range 0 to 65,535.
uint32β
uint32 = 138
32-bit unsigned integer, range 0 to 4,294,967,295.
uint64β
uint64 = 140
64-bit unsigned integer, range 0 to 18,446,744,073,709,551,615.
uint8β
uint8 = 134
8-bit unsigned integer, range 0 to 255.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!