Skip to main content

ONNX Optimizer

PyPI version PyPI license PRs Welcome

Introduction

ONNX provides a C++ library for performing arbitrary optimizations on ONNX models, as well as a growing list of prepackaged optimization passes.

The primary motivation is to share work between the many ONNX backend implementations. Not all possible optimizations can be directly implemented on ONNX graphs - some will need additional backend-specific information - but many can, and our aim is to provide all such passes along with ONNX so that they can be re-used with a single function call.

You may be interested in invoking the provided passes, or in implementing new ones (or both).

Installation

You can install onnxoptimizer from PyPI:

pip3 install onnxoptimizer

Note that you may need to upgrade your pip first if you have trouble:

pip3 install -U pip

If you want to build from source:

git clone --recursive https://github.com/onnx/optimizer onnxoptimizer
cd onnxoptimizer
pip3 install -e .

Note that you need to install protobuf before building from source.

Command-line API

Now you can use command-line api in terminal instead of python script.

python -m onnxoptimizer input_model.onnx output_model.onnx

Arguments list is following:

# python3 -m onnxoptimizer -h                                 
usage: python -m onnxoptimizer input_model.onnx output_model.onnx 

onnxoptimizer command-line api

optional arguments:
  -h, --help            show this help message and exit
  --print_all_passes    print all available passes
  --print_fuse_elimination_passes
                        print all fuse and elimination passes
  -p [PASSES ...], --passes [PASSES ...]
                        list of optimization passes name, if no set, fuse_and_elimination_passes will be used
  --fixed_point         fixed point

Roadmap

  • More built-in pass
  • Separate graph rewriting and constant folding (or a pure graph rewriting mode, see issue #9 for the details)

Relevant tools

Code of Conduct

ONNX Open Source Code of Conduct

Metadata

Release files for onnxoptimizer 0.4.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for onnxoptimizer 0.4.2
File Size Uploaded
onnxoptimizer-0.4.2.tar.gz 12.1 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for onnxoptimizer 0.4.2
File
onnxoptimizer-0.4.2-cp312-abi3-win_amd64.whl CPython 3.12 abi3 Windows x86-64 Details
onnxoptimizer-0.4.2-cp312-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 abi3 Linux glibc 2.28+ x86-64, Linux glibc 2.24+ x86-64 Details
onnxoptimizer-0.4.2-cp312-abi3-macosx_10_15_universal2.whl CPython 3.12 abi3 macOS 10.15+ universal2 (ARM64, x86-64) Details
onnxoptimizer-0.4.2-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
onnxoptimizer-0.4.2-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.24+ x86-64, Linux glibc 2.28+ x86-64 Details
onnxoptimizer-0.4.2-cp311-cp311-macosx_10_15_universal2.whl CPython 3.11 CPython 3.11 macOS 10.15+ universal2 (ARM64, x86-64) Details
onnxoptimizer-0.4.2-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
onnxoptimizer-0.4.2-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.24+ x86-64, Linux glibc 2.28+ x86-64 Details
onnxoptimizer-0.4.2-cp310-cp310-macosx_10_15_universal2.whl CPython 3.10 CPython 3.10 macOS 10.15+ universal2 (ARM64, x86-64) Details

Total release size: 20.2 MB

Release files / onnxoptimizer-0.4.2.tar.gz

Download URL onnxoptimizer-0.4.2.tar.gz
Size 12.1 MB
Tags Source
SHA-256 checksum
How to use checksums
dac4a972b5dc80a870b930e85e4b043d090d4546d7878106ef8448e07f94622e
BLAKE2b-256 checksum
How to use checksums
5ba7e4f0e67a7e077d7cc65b968febfc53f8f52d3a22257624aa7977f14fff8c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Jan 7, 2026.

Transparency log

Release files / onnxoptimizer-0.4.2-cp312-abi3-win_amd64.whl

Download URL onnxoptimizer-0.4.2-cp312-abi3-win_amd64.whl
Size 486.8 kB
Tags CPython 3.12 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
cc85d031f35689d36d91e79770611015014c41278fd39b664c6ccc27dc045aa0
BLAKE2b-256 checksum
How to use checksums
67c1173031e8e5f9185a168209ead6f8b5e985f951a817d7b7b9c62a335a1a33
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Jan 7, 2026.

Transparency log

Release files / onnxoptimizer-0.4.2-cp312-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL onnxoptimizer-0.4.2-cp312-abi3-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 1.0 MB
Tags CPython 3.12 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
af19ee4dd7a852a18511aeabdbe1e3c8b4dd8e02b187356965b269d480ac7147
BLAKE2b-256 checksum
How to use checksums
853ed512bf70a66f85d3d7bfc79380da24c026d6409b28c5cd48f2d91e450046
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Jan 7, 2026.

Transparency log

Release files / onnxoptimizer-0.4.2-cp312-abi3-macosx_10_15_universal2.whl

Download URL onnxoptimizer-0.4.2-cp312-abi3-macosx_10_15_universal2.whl
Size 1.2 MB
Tags CPython 3.12 abi3 macOS 10.15+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
7229ffe7d54c692e4ba0a2516f94805a4f462e7fce7634e080a381fb82ec2378
BLAKE2b-256 checksum
How to use checksums
e7e9bedd490a39b5201d33aea1f2812ca74bba9b30defa66fc94e3d46878b8b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Jan 7, 2026.

Transparency log

Release files / onnxoptimizer-0.4.2-cp311-cp311-win_amd64.whl

Download URL onnxoptimizer-0.4.2-cp311-cp311-win_amd64.whl
Size 488.2 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
74f5400833dbdd9439d17c0fd78b962fd2ae7a369169e41e19dd09ae532350b6
BLAKE2b-256 checksum
How to use checksums
e65a43b60c74ea2f3024340452962b0fbbf2300907d4e88e31847f4e67faa631
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Jan 7, 2026.

Transparency log

Release files / onnxoptimizer-0.4.2-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL onnxoptimizer-0.4.2-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 1.0 MB
Tags CPython 3.11 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
f278dc846b7144b7bdd063d0838848bdf45ce2e35d205379f169ec77deb76d9e
BLAKE2b-256 checksum
How to use checksums
cc7c99b072778f66e0f95e43874f6a2fd2b96968979e1fb644d186abbed2f2e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Jan 7, 2026.

Transparency log

Release files / onnxoptimizer-0.4.2-cp311-cp311-macosx_10_15_universal2.whl

Download URL onnxoptimizer-0.4.2-cp311-cp311-macosx_10_15_universal2.whl
Size 1.2 MB
Tags CPython 3.11 macOS 10.15+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
b6aeaf03ecfa626b2e716ce910b1547d450d4b79673ab1c446fd761c05c8dcf8
BLAKE2b-256 checksum
How to use checksums
f8f4c0eae052169bb058c847f9ed3a4c217e2a3b2f63177e370b1ee2afd2e614
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Jan 7, 2026.

Transparency log

Release files / onnxoptimizer-0.4.2-cp310-cp310-win_amd64.whl

Download URL onnxoptimizer-0.4.2-cp310-cp310-win_amd64.whl
Size 488.1 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
65185aa0a3629db7d6618762dfb6ec1afa19401048773318191eef7b55eb142c
BLAKE2b-256 checksum
How to use checksums
b02815ed9afb400f964cd4f1ab0bb790623d2d2a6acf755221cc717c34492b3e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Jan 7, 2026.

Transparency log

Release files / onnxoptimizer-0.4.2-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL onnxoptimizer-0.4.2-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 1.0 MB
Tags CPython 3.10 Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
ee2ed3cc6cc08543fc542c65d49bf2a8933e185b454d576ae3cd1bc877ee858c
BLAKE2b-256 checksum
How to use checksums
389c09f01912085cd8f2c1a1bcd6d74106d85e839f0b06fc705b843086553a8e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Jan 7, 2026.

Transparency log

Release files / onnxoptimizer-0.4.2-cp310-cp310-macosx_10_15_universal2.whl

Download URL onnxoptimizer-0.4.2-cp310-cp310-macosx_10_15_universal2.whl
Size 1.2 MB
Tags CPython 3.10 macOS 10.15+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
73b0859397ea1ffca6e896c6799c48933f09b16226def686264e68ef386f1239
BLAKE2b-256 checksum
How to use checksums
b7601e08c455e8262b7a8ecc2c10e586a7aaa517c0b9e3771b3c7b5ec80b6f29
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Jan 7, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.4.2 This release

10 release files

0.4.1

9 release files

0.3.9

20 release files

0.3.8

16 release files

0.3.2

10 release files

0.3.1

10 release files

0.2.6

12 release files

0.2.5

12 release files

0.2.4

12 release files

0.2.3

12 release files

0.2.2

12 release files

0.2.1

12 release files

0.2.0

12 release files

0.1.2

12 release files

0.1.1

12 release files

0.1.0

12 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page