Convert ONNX models into MLX callables for accelerating inference on Apple Silicon.
Open a terminal and run the following command:
# Install onnx2mlx
$ pip install --upgrade onnx2mlxUse the onnx2mlx function to create a callable that uses MLX to run the model:
import mlx.core as mx
import onnx
from onnx2mlx import onnx2mlx
# Load an ONNX model
model = onnx.load("model.onnx")
# Convert to MLX
model_mlx = onnx2mlx(onnx_model)
# Run the MLX model
outputs = model_mlx(mx.array(...))- Join our Slack community.
- Check out the docs.
- Read our blog.
- Reach out to us at [email protected].
