mlx.core.load

目录

mlx.core.load#

load(file: file | str | Path, /, format: str | None = None, return_metadata: bool = False, *, stream: None | Stream | Device = None) array | dict[str, array] | Tuple[dict[str, array], dict[str, Any]]#

Load array(s) from a binary file.

The supported formats are .npy, .npz, .safetensors, and .gguf.

参数:
  • file (file, str, Path) -- 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, and safetensors. 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.

返回:

A single array if loading from a .npy file or a dict mapping names to arrays if loading from a .npz or .safetensors file. If return_metadata is True a tuple (arrays, metadata) will be returned where the second element is a dictionary containing the metadata.

返回类型:

array, dict, or tuple

警告

When loading unsupported quantization formats from GGUF, tensors will automatically cast to mx.float16