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!