mlx.core.load#
- load(file: str, /, format: str | None = None, return_metadata: bool = False, *, stream: None | Stream | Device = None) array | dict[str, array] #
Load array(s) from a binary file.
The supported formats are
.npy
,.npz
,.safetensors
, and.gguf
.- Parameters:
file (file, str) – File in which the array is saved.
format (str, optional) – Format of the file. If
None
, the format is inferred from the file extension. Supported formats:npy
,npz
, andsafetensors
. Default:None
.return_metadata (bool, optional) – Load the metadata for formats which support matadata. The metadata will be returned as an additional dictionary. Default:
False
.
- Returns:
A single array if loading from a
.npy
file or a dict mapping names to arrays if loading from a.npz
or.safetensors
file. Ifreturn_metadata` is ``True
an additional dictionary of metadata will be returned.- Return type:
Warning
When loading unsupported quantization formats from GGUF, tensors will automatically cast to
mx.float16