Skip to main content
Archived

This project has been archived by its maintainers, and is no longer receiving any updates.

ONNX Simplifier Prebuilt

PyPI version PyPI pyversions PyPI license Build and Test

onnxsim-prebuilt is a fork of onnxsim that aims to publish prebuilt wheels for Python 3.12 and later to PyPI.

Changes in this fork

  • Changed package name to onnxsim-prebuilt
    • The library name remains unchanged from onnxsim, so you can import it as import onnxsim just like the original onnxsim
    • Can be used as a drop-in replacement for the original onnxsim
  • Publish prebuilt wheels for all platforms (Windows, macOS x64/arm64, Linux x64/arm64) on PyPI
    • onnx-simplifier depends on C++, CMake, and submodules, making the build environment setup relatively difficult and time-consuming
      • For over a year, onnxsim has not been updated, and prebuilt wheels for Python 3.12/3.13 are not available (ref: onnxsim/issues/334, onnxsim/pull/359)
      • Various issues arise, such as the need to install build-essentials and CMake in Docker images just for installation, and long build times
    • By publishing prebuilt wheels on PyPI, we aim to enable easy installation even on PCs without a build environment
    • Incorporated the CI improvements proposed in the pull request onnxsim/pull/359, and further enhanced it to build and publish prebuilt wheels for Linux aarch64
  • Explicitly added Python 3.12 / 3.13 to supported versions
    • Changed CI target Python versions to Python 3.10 and above
    • This fork does not support Python 3.9 and below

Installation

You can install the library by running the following command:

pip install onnxsim-prebuilt

The documentation below is inherited from the original onnxsim without any modifications.
There is no guarantee that the content of this documentation applies to onnxsim-prebuilt.


ONNX Simplifier

PyPI version PyPI pyversions PyPI license PRs Welcome

ONNX is great, but sometimes too complicated.

Background

One day I wanted to export the following simple reshape operation to ONNX:

import torch


class JustReshape(torch.nn.Module):
    def __init__(self):
        super(JustReshape, self).__init__()

    def forward(self, x):
        return x.view((x.shape[0], x.shape[1], x.shape[3], x.shape[2]))


net = JustReshape()
model_name = 'just_reshape.onnx'
dummy_input = torch.randn(2, 3, 4, 5)
torch.onnx.export(net, dummy_input, model_name, input_names=['input'], output_names=['output'])

The input shape in this model is static, so what I expected is

simple_reshape

However, I got the following complicated model instead:

complicated_reshape

Our solution

ONNX Simplifier is presented to simplify the ONNX model. It infers the whole computation graph and then replaces the redundant operators with their constant outputs (a.k.a. constant folding).

Web version

We have published ONNX Simplifier on convertmodel.com. It works out of the box and doesn't need any installation. Note that it runs in the browser locally and your model is completely safe.

Python version

pip3 install -U pip && pip3 install onnxsim

Then

onnxsim input_onnx_model output_onnx_model

For more advanced features, try the following command for help message

onnxsim -h

Demonstration

An overall comparison between a complicated model and its simplified version:

Comparison between old model and new model

In-script workflow

If you would like to embed ONNX simplifier python package in another script, it is just that simple.

import onnx
from onnxsim import simplify

# load your predefined ONNX model
model = onnx.load(filename)

# convert model
model_simp, check = simplify(model)

assert check, "Simplified ONNX model could not be validated"

# use model_simp as a standard ONNX model object

You can see more details of the API in onnxsim/onnx_simplifier.py

Projects Using ONNX Simplifier

Chat

We created a Chinese QQ group for ONNX!

ONNX QQ Group (Chinese): 1021964010, verification code: nndab. Welcome to join!

For English users, I'm active on the ONNX Slack. You can find and chat with me (daquexian) there.

Metadata

Release files for onnxsim-prebuilt 0.4.39.post2

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

Source distribution (sdist)

Source distribution for onnxsim-prebuilt 0.4.39.post2
File Size Uploaded Provenance Actions
onnxsim_prebuilt-0.4.39.post2.tar.gz 12.2 MB Without provenance Details for onnxsim_prebuilt-0.4.39.post2.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for onnxsim-prebuilt 0.4.39.post2
File Actions
onnxsim_prebuilt-0.4.39.post2-cp312-abi3-win_amd64.whl CPython 3.12 abi3 Windows x86-64 Details for onnxsim_prebuilt-0.4.39.post2-cp312-abi3-win_amd64.whl
onnxsim_prebuilt-0.4.39.post2-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 abi3 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details for onnxsim_prebuilt-0.4.39.post2-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
onnxsim_prebuilt-0.4.39.post2-cp312-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl CPython 3.12 abi3 Linux glibc 2.28+ ARM64, Linux glibc 2.26+ ARM64 Details for onnxsim_prebuilt-0.4.39.post2-cp312-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
onnxsim_prebuilt-0.4.39.post2-cp312-abi3-macosx_10_15_universal2.whl CPython 3.12 abi3 macOS 10.15+ universal2 (ARM64, x86-64) Details for onnxsim_prebuilt-0.4.39.post2-cp312-abi3-macosx_10_15_universal2.whl
onnxsim_prebuilt-0.4.39.post2-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details for onnxsim_prebuilt-0.4.39.post2-cp311-cp311-win_amd64.whl
onnxsim_prebuilt-0.4.39.post2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details for onnxsim_prebuilt-0.4.39.post2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
onnxsim_prebuilt-0.4.39.post2-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ ARM64, Linux glibc 2.26+ ARM64 Details for onnxsim_prebuilt-0.4.39.post2-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
onnxsim_prebuilt-0.4.39.post2-cp311-cp311-macosx_10_15_universal2.whl CPython 3.11 CPython 3.11 macOS 10.15+ universal2 (ARM64, x86-64) Details for onnxsim_prebuilt-0.4.39.post2-cp311-cp311-macosx_10_15_universal2.whl
onnxsim_prebuilt-0.4.39.post2-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details for onnxsim_prebuilt-0.4.39.post2-cp310-cp310-win_amd64.whl
onnxsim_prebuilt-0.4.39.post2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details for onnxsim_prebuilt-0.4.39.post2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
onnxsim_prebuilt-0.4.39.post2-cp310-cp310-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl CPython 3.10 CPython 3.10 Linux glibc 2.26+ ARM64, Linux glibc 2.28+ ARM64 Details for onnxsim_prebuilt-0.4.39.post2-cp310-cp310-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
onnxsim_prebuilt-0.4.39.post2-cp310-cp310-macosx_10_15_universal2.whl CPython 3.10 CPython 3.10 macOS 10.15+ universal2 (ARM64, x86-64) Details for onnxsim_prebuilt-0.4.39.post2-cp310-cp310-macosx_10_15_universal2.whl

Total release size: 43.9 MB

Release files / onnxsim_prebuilt-0.4.39.post2.tar.gz

Download URL onnxsim_prebuilt-0.4.39.post2.tar.gz
Size 12.2 MB
Tags Source
SHA-256 checksum
How to use checksums
731420cd8830d2ebde341c41abac1b718718891db4934f2655d7ec4df0b100fd
BLAKE2b-256 checksum
How to use checksums
89399d05c88e05b4495d870b96244808bcec89bddf0d6de7fb37a1dfaec32a83
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.8

Release files / onnxsim_prebuilt-0.4.39.post2-cp312-abi3-win_amd64.whl

Download URL onnxsim_prebuilt-0.4.39.post2-cp312-abi3-win_amd64.whl
Size 1.6 MB
Tags CPython 3.12 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
ddfa75679246e51b1cc55e37d02b473c653c906b2987f817c220adf2c90f1cf2
BLAKE2b-256 checksum
How to use checksums
fe8c5e69d067256f7e27b6905e8a16938097a98d563f8dc9f0c7171fd4a9da29
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.8

Release files / onnxsim_prebuilt-0.4.39.post2-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL onnxsim_prebuilt-0.4.39.post2-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 2.8 MB
Tags CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
5f129c78b379f040caafc40360db1db91617179c0663049e712c7dde4a0d6c28
BLAKE2b-256 checksum
How to use checksums
643a677d73f0fd8a0a9baa58e470e4d70f6ff3cffce432c2b3e35802c56ae175
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.8

Release files / onnxsim_prebuilt-0.4.39.post2-cp312-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl

Download URL onnxsim_prebuilt-0.4.39.post2-cp312-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Size 2.5 MB
Tags CPython 3.12 Linux glibc 2.26+ ARM64 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
59b671d008fb5f8c51cd20c3c06475e64dd6267659f61912cf1579bee25d9405
BLAKE2b-256 checksum
How to use checksums
a0ad88c7ef2d16e6c78577363abf0656f207a6130da5a8b00d3a9bd67313dfc7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.8

Release files / onnxsim_prebuilt-0.4.39.post2-cp312-abi3-macosx_10_15_universal2.whl

Download URL onnxsim_prebuilt-0.4.39.post2-cp312-abi3-macosx_10_15_universal2.whl
Size 3.7 MB
Tags CPython 3.12 abi3 macOS 10.15+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
b454921fb8f6f4f48ef26e49fa629074d3a0428c0f1e4f746215a7d7f0b72944
BLAKE2b-256 checksum
How to use checksums
7c540197a7ab94785031517513f326e804558baba41537d37dc77fe0c359fada
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.8

Release files / onnxsim_prebuilt-0.4.39.post2-cp311-cp311-win_amd64.whl

Download URL onnxsim_prebuilt-0.4.39.post2-cp311-cp311-win_amd64.whl
Size 1.6 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
ad2ea55e44901bacac5a592bcd1a6fa8b34540e7047b59d906b3689bbc939d26
BLAKE2b-256 checksum
How to use checksums
21ae175559f7d1fe7d68ff587e160cd694553c75fa7c766ec591f13eb43b063b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.8

Release files / onnxsim_prebuilt-0.4.39.post2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL onnxsim_prebuilt-0.4.39.post2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 2.8 MB
Tags CPython 3.11 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
bf2f4688ac48072a4706873609ceec00f65ac397c45460837f827a04b73d872e
BLAKE2b-256 checksum
How to use checksums
e8f0f2b4b5d14823a73bcc3a07178ecdec47a2c021a96f85fd75cf85b7d7275b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.8

Release files / onnxsim_prebuilt-0.4.39.post2-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl

Download URL onnxsim_prebuilt-0.4.39.post2-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Size 2.5 MB
Tags CPython 3.11 Linux glibc 2.26+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
f883fd21d2ab0f3f6253366a3963911011ab80f4748b1a83949170cf2f120ad8
BLAKE2b-256 checksum
How to use checksums
ce54867845c3fee32a5fd1f0e0def8296a648789e0ca3ba370afa39db4adb689
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.8

Release files / onnxsim_prebuilt-0.4.39.post2-cp311-cp311-macosx_10_15_universal2.whl

Download URL onnxsim_prebuilt-0.4.39.post2-cp311-cp311-macosx_10_15_universal2.whl
Size 3.7 MB
Tags CPython 3.11 macOS 10.15+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
78ccc734fbb6c037a89e9d8a9e0b4abcda000854e6d2bad64cf497a3ce92bdc1
BLAKE2b-256 checksum
How to use checksums
19e8088b2920990cd37840c8624ff02efa18318c61e77500071ae17860e31ef1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.8

Release files / onnxsim_prebuilt-0.4.39.post2-cp310-cp310-win_amd64.whl

Download URL onnxsim_prebuilt-0.4.39.post2-cp310-cp310-win_amd64.whl
Size 1.6 MB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
85670a8885e34c56920ae4f4f16afe3d3ed9019d5d92981b0f1af7318374f3dc
BLAKE2b-256 checksum
How to use checksums
7de7fc82d055f245b352e77f7bccf67a84be28afb1ecf7ed15cd48a33f6d0315
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.8

Release files / onnxsim_prebuilt-0.4.39.post2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL onnxsim_prebuilt-0.4.39.post2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 2.8 MB
Tags CPython 3.10 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
39ff782c82c8fe3ebf0fc9a6fa8f29da6787325f09325327b5c9e6c86720562e
BLAKE2b-256 checksum
How to use checksums
bad059bed073ec37f252da8d72055dfaca49d999edc3150cd3401c081dee6d64
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.8

Release files / onnxsim_prebuilt-0.4.39.post2-cp310-cp310-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl

Download URL onnxsim_prebuilt-0.4.39.post2-cp310-cp310-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Size 2.5 MB
Tags CPython 3.10 Linux glibc 2.26+ ARM64 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
05143aa0609822d5c1a7ab00077e6c76b74ce8483934185a050fe4530325de0c
BLAKE2b-256 checksum
How to use checksums
2fded473eb52675a20a4c05938a7e5c9a8f6819da5e9a7f1f34349b85c90796e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.8

Release files / onnxsim_prebuilt-0.4.39.post2-cp310-cp310-macosx_10_15_universal2.whl

Download URL onnxsim_prebuilt-0.4.39.post2-cp310-cp310-macosx_10_15_universal2.whl
Size 3.7 MB
Tags CPython 3.10 macOS 10.15+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
c1e061dc142cc1eb5b483c37e85267bfde065f32fdc4f6c3e2bad5d4e0209661
BLAKE2b-256 checksum
How to use checksums
884841df16eb40188fdfda61cc0b917352ea3a412f21fe81a8d44d4b521ca224
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.8

Security for onnxsim-prebuilt 0.4.39.post2

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A 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.

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