mlx.core.import_function

mlx.core.import_function#

import_function(file: str, return_metadata: bool = False) → Callable | tuple[Callable, str]#

從檔案匯入函式。

The imported function can be called either with *args and **kwargs or with a tuple of arrays and/or dictionary of string keys with array values. Imported functions always return a tuple of arrays.

警告

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.

參數:
  • file (str) -- The file path to import the function from.

  • return_metadata (bool, optional) -- If True also return the metadata string saved with the function. Default: False.

回傳值:

The imported function. If return_metadata is True a tuple of the imported function and the metadata string is returned instead.

回傳值型別:

Callable or tuple

範例

>>> fn = mx.import_function("function.mlxfn")
>>> out = fn(a, b, x=x, y=y)[0]
>>>
>>> out = fn((a, b), {"x": x, "y": y})[0]