Skip to main content

onnx-cse

CI

onnx-cse is a tiny library for common subexpression elimination (CSE) from ONNX models.

Example usage

The onnx_cse package provides a single function:

from onnx_cse import eliminate_common_subexpressions
import onnx

model = onnx.load_model("model.onnx")
# Update model in-place
eliminate_common_subexpressions(model)

Comparisons

It is written in pure Python with minimal dependencies and focuses on being safe, fast, and simple. It differs from similar tools such as onnxoptimizer, onnx-simplifier, and onnxruntimes own CSE-pass in the following ways:

Simplicity

onnx-cse does one thing (CSE) but does it well. The entire library is less then a couple of hundred lines of code and easy to understand for anybody interested.

Performance

From personal experience onnx-cse handily outperforms onnxruntime's CSE pass on very large graphs with small weights (~10k nodes with nested subgraphs) while onnxoptimizer fails to finish its operation on such graphs at all.

Optimization across subgraph boundaries

onnx-cse eliminates subexpressions in subgraphs if they can be replaced with expressions found in the enclosing scope.

Installation

pypi

pip install onnx-cse

conda-forge

Using pixi:

pixi add onnx-cse

or using conda:

conda install onnx-cse

Development

You can install the package in development mode using:

git clone https://github.com/cbourjau/onnx-cse
cd onnx-cse
pixi run pre-commit-install
pixi run postinstall
pixi run test

Metadata

Release files for onnx-cse 0.3.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 onnx-cse 0.3.2
File Size Uploaded Provenance Actions
onnx_cse-0.3.2.tar.gz 81.0 kB With provenance Details for onnx_cse-0.3.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for onnx-cse 0.3.2
File Interpreter ABI Platform Actions
onnx_cse-0.3.2-py3-none-any.whl Python 3 none any Details for onnx_cse-0.3.2-py3-none-any.whl

Total release size: 86.5 kB

Release files / onnx_cse-0.3.2.tar.gz

Download URL onnx_cse-0.3.2.tar.gz
Size 81.0 kB
Tags Source
SHA-256 checksum
How to use checksums
3eae73f3c4d3278baafd54bffbffaeb388c7e09650c2fe8430684f2071239612
BLAKE2b-256 checksum
How to use checksums
b5ac2ed1addd1e1a164700283e78261a8247a3b0d302221bbc5b9454721cc71e
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 Nov 23, 2026.

Transparency log

Release files / onnx_cse-0.3.2-py3-none-any.whl

Download URL onnx_cse-0.3.2-py3-none-any.whl
Size 5.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a5a99aa2563cc3099775aeb1db75a114a7037ba87ab04677ad6324d67e2c376c
BLAKE2b-256 checksum
How to use checksums
201da2e40b7fdff42e3eb3d5d45c26ffbccd293e99f4e6ab23642aede2300c92
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 Nov 23, 2026.

Transparency log

Security for onnx-cse 0.3.2

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.

Select from 2 files

Attestation for onnx_cse-0.3.2.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 Nov 23, 2026.

Transparency log

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