mlx.core.exporter

目录

mlx.core.exporter#

exporter(file: str, fun: Callable, *, shapeless: bool = False) mlx.core.FunctionExporter#

创建一个可调用对象,用于将函数的多个跟踪导出到文件。

警告

这是实验性 API 的一部分,未来版本的 MLX 中可能会发生变化。使用旧版本 MLX 导出的函数可能与未来版本不兼容。

参数:
  • file (str) – 要将函数导出的文件路径。

  • shapeless (bool, optional) – 函数是否允许输入具有可变形状。默认值:False

示例

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))