mlx.core.exporter#
- exporter(file: str, fun: Callable, *, shapeless: bool = False, metadata: str | None = None) mlx.core.FunctionExporter#
Make a callable object to export multiple traces of a function to a file.
Warning
This is part of an experimental API which is likely to change in future versions of MLX. Functions exported with older versions of MLX may not be compatible with future versions.
- Parameters:
file (str) – File path to export the function to.
shapeless (bool, optional) – Whether or not the function allows inputs with variable shapes. Default:
False.metadata (str, optional) – A string to save alongside the function, for example a JSON encoded model configuration. Read it back with
import_function(). Default:None.
Example
def fun(*args): return sum(args) with mx.exporter("fun.mlxfn", fun) as exporter: exporter(mx.array(1)) exporter(mx.array(1), mx.array(2)) exporter(mx.array(1), mx.array(2), mx.array(3))