MLX 分区器配置模型委托与不支持算子日志
介绍 ExecuTorch 的 MLX 分区器 API,说明如何用默认配置把模型尽可能多地委托给 MLX 后端,并解释分区器输出的不支持算子摘要与调试开关的作用。
## 分区器 API[#](<https://docs.pytorch.org/executorch/stable/backends/mlx/mlx-partitioner.html#partitioner-api>) MLX 分区器 API 允许配置模型代表团到MLX后端. Passing a `MLXPartitioner` 实例中,没有附加参数的模型将尽可能在默认设置的 MLX 后端运行。这是最常见的使用例。 ## 使用量[#](<https://docs.pytorch.org/executorch/stable/backends/mlx/mlx-partitioner.html#usage>) ``` import torch from executorch.backends.mlx import MLXPartitioner from executorch.exir import to_edge_transform_and_lower et_program = to_edge_transform_and_lower( torch.export.export(model, example_inputs), partitioner=[MLXPartitioner()], ).to_executorch() ``` 重要 `MLXPartitioner` 必须是用于 `to_edge_transform_and_lower()`. 遗产 `to_edge()` + `to_backend()` 工作流程为 **不支持 。** 因为它分解了MLX已经优化了执行功能的操作. ## 不支持的 Op 日志[#](<https://docs.pytorch.org/executorch/stable/backends/mlx/mlx-partitioner.html#unsupported-op-logging>) 分区时, 分区器会记录任何不支持的操作摘要。 这对于理解会回到 CPU 的操作很有用 : ``` ================================================================================ MLX Partitioner: UNSUPPORTED OPS SUMMARY ================================================================================ [UNSUPPORTED x2] aten.some_op.default Reason: No handler registered ================================================================================ ``` 如果所有行动都得到支持,你会看到: ``` (All call_function nodes are supported!) ``` 设定 `ET_MLX_DEBUG=1` 在分区时看到每个节点的详细支持决定。
查看原始来源