mlx.core.load#
- mlx.core.load(file: str, /, format: Optional[str] = None, return_metadata: bool = False, *, stream: Union[None, Stream, Device] = None) Union[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.
- Returns:
A single array if loading from a
.npyfile or a dict mapping names to arrays if loading from a.npzor.safetensorsfile. Ifreturn_metadata` is ``Truean additional dictionary of metadata will be returned.- Return type:
Warning
When loading unsupported quantization formats from GGUF, tensors will automatically cast to
mx.float16