onnx2coreml
Convert ONNX models to Apple Core ML — .mlpackage (ML Program / MIL, primary) and
.mlmodel (NeuralNetwork, secondary) — built on coremltools' MIL builder, with
numerical-parity verification against ONNX Runtime.
- ML Program first for modern on-device performance (fp16 and Apple Neural Engine), with full NeuralNetwork support for older-OS reach.
- Maintainable as Core ML evolves: all coremltools coupling is isolated behind two facades, so spec/format changes touch two files, not the operator lowerings.
- Verified, not assumed: every operator has numerical-parity tests run against the live Core ML runtime on macOS.
Install
uv pip install onnx2coreml # from PyPI
# from a clone, for development:
uv pip install -e ".[dev,verify,test]"
Requires Python 3.11–3.13 and macOS for prediction/verification (model building works anywhere coremltools installs).
Quickstart
import onnx2coreml as o2c
# ML Program (.mlpackage) — the default, fp16, iOS17+
mlmodel = o2c.convert("model.onnx", format="mlpackage", minimum_deployment_target="iOS17")
mlmodel.save("model.mlpackage")
# NeuralNetwork (.mlmodel)
o2c.convert("model.onnx", format="mlmodel").save("model.mlmodel")
# Check coverage before converting
report = o2c.analyze("model.onnx")
print(report.convertible, report.unsupported)
# Numerical parity vs ONNX Runtime
print(o2c.verify("model.onnx", "model.mlpackage"))
convert() returns a coremltools MLModel. Options: format,
minimum_deployment_target, compute_precision (fp16/fp32), compute_units,
fuse, verify.
CLI
onnx2coreml convert model.onnx -o model.mlpackage --format mlpackage --verify
onnx2coreml inspect model.onnx # op histogram + per-format convertibility
onnx2coreml verify model.onnx model.mlpackage
onnx2coreml schema # version, supported op count, error codes
All subcommands accept --json.
Supported operators (106 ops)
| Family | Operators |
|---|---|
| Elementwise / math | Add, Sub, Mul, Div, Pow, Sqrt, Exp, Log, Abs, Erf, Reciprocal, Neg, Floor, Ceil, Round, Sign, Sin, Cos, Tan, Asin, Acos, Atan, Sinh, Cosh, Atanh, Min, Max, Clip, Mod, Equal, Greater, Less, GreaterOrEqual, LessOrEqual, And, Or, Xor, Not, IsNaN, Where |
| Activations | Relu, LeakyRelu, PRelu, Sigmoid, Tanh, Gelu, Softmax, LogSoftmax, Softplus, Elu, HardSigmoid, HardSwish |
| Convolution / pooling | Conv, ConvTranspose, MaxPool, AveragePool, GlobalAveragePool, GlobalMaxPool |
| Normalization | BatchNormalization, LayerNormalization, InstanceNormalization, GroupNormalization |
| Linear | MatMul, Gemm, Inverse (com.microsoft) |
| Shape / movement | Reshape, Transpose, Flatten, Squeeze, Unsqueeze, Concat, Split, Pad, Cast, Identity, DepthToSpace, SpaceToDepth, GridSample, Resize, Upsample |
| Indexing / gather-scatter | Gather, GatherND, GatherElements, ScatterND, ScatterElements, NonZero, Slice, Expand, Tile, Shape, ConstantOfShape |
| Reduction | ReduceMean, ReduceSum, ReduceMax, ReduceMin, ReduceProd, ReduceL1, ReduceL2, ReduceLogSum, ReduceLogSumExp, ReduceSumSquare, ArgMax, ArgMin, TopK |
| Recurrent | LSTM |
| Attention | ScaledDotProductAttention (produced by the attention fusion pass) |
onnx2coreml inspect <model> reports exactly which ops a given model needs and whether
each is covered. Unsupported ops raise a single aggregated UnsupportedOpError; register
a custom lowering with Converter().register("OpType") as an escape hatch.
How it works
ONNX → load → passes (opset/shape/fold/cleanup) → fusion (attention→SDPA) →
coverage-gate → lower to MIL (mb.*) → coremltools backend → .mlpackage / .mlmodel → verify
See AGENTS.md for the developer guide and architecture overview.
Known limitations (v1.1.0)
- Fixed input shapes.
- A full all-axes reduction with
keepdims=0yields shape(1,)(Core ML has no rank-0 scalar). - Resize
linear+half_pixelvia explicit sizes is.mlpackage-only (the NeuralNetwork backend lacks the sampling mode); the scales path covers it on both formats.
License
BSD-3-Clause.
Metadata
Release files for onnx2coreml 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| onnx2coreml-1.1.0.tar.gz | 72.5 kB | With provenance | Details for onnx2coreml-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| onnx2coreml-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for onnx2coreml-1.1.0-py3-none-any.whl |
Total release size: 139.7 kB
Release files / onnx2coreml-1.1.0.tar.gz
| Download URL | onnx2coreml-1.1.0.tar.gz |
|---|---|
| Size | 72.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7c5316d8e76879f5f4aefee1aac30eb7ad1505c9370935f81bc632ea1dd9a6d6
|
|
BLAKE2b-256 checksum How to use checksums |
4342fb949967780b52b0c5312dd11033b38345c0067554546549f461a937be8b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 17, 2026.
Transparency logRelease files / onnx2coreml-1.1.0-py3-none-any.whl
| Download URL | onnx2coreml-1.1.0-py3-none-any.whl |
|---|---|
| Size | 67.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4afbf23d784c12d40b6a60d335d44e03e5bc2c312121d0fa9fbe2e47a2b093e6
|
|
BLAKE2b-256 checksum How to use checksums |
848a254b7edb63ee69898bdf71a75760719b62929de61d446ae4bb091d607e6b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 17, 2026.
Transparency logSecurity for onnx2coreml 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for onnx2coreml-1.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 17, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.