float32 and the default integer type is int32.
Supported Data Types
Boolean Type
bool_
Boolean data type representingTrue or False values.
Integer Types
int8
8-bit signed integer. Range: -128 to 127Size: 1 byte
int16
16-bit signed integer. Range: -32,768 to 32,767Size: 2 bytes
int32
32-bit signed integer. This is the default integer type. Range: -2,147,483,648 to 2,147,483,647Size: 4 bytes
int64
64-bit signed integer. Range: -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807Size: 8 bytes
Unsigned Integer Types
uint8
8-bit unsigned integer. Range: 0 to 255Size: 1 byte
uint16
16-bit unsigned integer. Range: 0 to 65,535Size: 2 bytes
uint32
32-bit unsigned integer. Range: 0 to 4,294,967,295Size: 4 bytes
uint64
64-bit unsigned integer. Range: 0 to 18,446,744,073,709,551,615Size: 8 bytes
Floating Point Types
float16
16-bit IEEE 754 floating point (half precision). Format: 1 sign bit, 5 exponent bits, 10 mantissa bitsSize: 2 bytes
bfloat16
16-bit brain floating point. Format: 1 sign bit, 8 exponent bits, 7 mantissa bitsSize: 2 bytes
bfloat16 has the same exponent range as float32 but with reduced precision, making it useful for machine learning applications.
float32
32-bit IEEE 754 floating point (single precision). This is the default floating point type. Format: 1 sign bit, 8 exponent bits, 23 mantissa bitsSize: 4 bytes
float64
64-bit IEEE 754 floating point (double precision). Format: 1 sign bit, 11 exponent bits, 52 mantissa bitsSize: 8 bytes
Complex Types
complex64
64-bit complex floating point number. Format: Two 32-bit floats (real and imaginary parts)Size: 8 bytes
Data Type Utilities
Dtype
TheDtype class represents the data type of an array.
The size of the data type in bytes.
DtypeCategory
Data types are arranged in a hierarchy of categories. TheDtypeCategory class represents these categories.
Categories:
complexfloating: Complex floating point typesfloating: Floating point typessignedinteger: Signed integer typesunsignedinteger: Unsigned integer typesinexact: Floating point and complex typesnumber: All numeric typesgeneric: All types
issubdtype
Determine if one data type is a subtype of another.The data type or category to check.
The category to check against.
True if arg1 is a subtype of arg2, False otherwise.
finfo
Machine limits for floating point types.A floating point data type. Raises ValueError for non-floating point types.
An object with the following attributes:
min: Smallest representable numbermax: Largest representable numbereps: Machine epsilon (smallest positive number such that 1.0 + eps != 1.0)dtype: The data type
iinfo
Machine limits for integer types.An integer data type. Raises ValueError for non-integer types.
An object with the following attributes:
min: Smallest representable numbermax: Largest representable numberdtype: The data type
Type Conversion
Arrays can be converted between types using theastype method.
Type Promotion
When operating on arrays with different types, MLX automatically promotes them to a common type.Data Type Naming
MLX data types follow NumPy naming conventions:- Boolean:
bool_(underscore avoids conflict with Python’sbool) - Integers:
int8,int16,int32,int64 - Unsigned integers:
uint8,uint16,uint32,uint64 - Floats:
float16,bfloat16,float32,float64 - Complex:
complex64