onnx-cse
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.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| onnx_cse-0.3.1.tar.gz | 80.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| onnx_cse-0.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 86.2 kB
Release files / onnx_cse-0.3.1.tar.gz
| Download URL | onnx_cse-0.3.1.tar.gz |
|---|---|
| Size | 80.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d8d91fc0ed751666b925f8908013a31cb7b517e5459ee6f3324477b513c0eded
|
|
BLAKE2b-256 checksum How to use checksums |
5ffc910d93696d71de84bf99f37b5ed390ff4807e9cf9a15c35d34a7c4e05081
|
| 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 Jun 22, 2026.
Transparency logRelease files / onnx_cse-0.3.1-py3-none-any.whl
| Download URL | onnx_cse-0.3.1-py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cfbc6a01182cb1252fbb30fe149bc73adaf5ea0d03d19f74d98da0cde58b6376
|
|
BLAKE2b-256 checksum How to use checksums |
921b9b578fef3133eface8891e2f9d3e79c404bb73b64d28cf533f44a9d7a965
|
| 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 Jun 22, 2026.
Transparency log