Common subexpression elimination for ONNX graphs
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file onnx_cse-0.1.1.tar.gz.
File metadata
- Download URL: onnx_cse-0.1.1.tar.gz
- Upload date:
- Size: 87.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b525ae7b10f099dbc7d6cd90961ceab15849be54ced24fb50a4473e1c7ee4560
|
|
| MD5 |
2e01faa7d9484c8607d1581164cfef95
|
|
| BLAKE2b-256 |
6b94262a049e6793c91da209190b353393d197cbae38e6bbd0dfdf7f2ed0a1a0
|
Provenance
The following attestation bundles were made for onnx_cse-0.1.1.tar.gz:
Publisher:
package.yml on cbourjau/onnx-cse
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
onnx_cse-0.1.1.tar.gz -
Subject digest:
b525ae7b10f099dbc7d6cd90961ceab15849be54ced24fb50a4473e1c7ee4560 - Sigstore transparency entry: 867813235
- Sigstore integration time:
-
Permalink:
cbourjau/onnx-cse@409bfff33f7f1318632a301b584fecff4ae4093a -
Branch / Tag:
refs/tags/0.1.1 - Owner: https://github.com/cbourjau
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
package.yml@409bfff33f7f1318632a301b584fecff4ae4093a -
Trigger Event:
push
-
Statement type:
File details
Details for the file onnx_cse-0.1.1-py3-none-any.whl.
File metadata
- Download URL: onnx_cse-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0d088a392710d0029ed13adb47dca8dc3a7784d100632545a3ee4919938cce99
|
|
| MD5 |
944ec0f389b3d44a538ce27ec5f12d88
|
|
| BLAKE2b-256 |
557722bc88000481f74f4be180fb40f8b411690018e21eb0954820b0c60b9bad
|
Provenance
The following attestation bundles were made for onnx_cse-0.1.1-py3-none-any.whl:
Publisher:
package.yml on cbourjau/onnx-cse
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
onnx_cse-0.1.1-py3-none-any.whl -
Subject digest:
0d088a392710d0029ed13adb47dca8dc3a7784d100632545a3ee4919938cce99 - Sigstore transparency entry: 867813250
- Sigstore integration time:
-
Permalink:
cbourjau/onnx-cse@409bfff33f7f1318632a301b584fecff4ae4093a -
Branch / Tag:
refs/tags/0.1.1 - Owner: https://github.com/cbourjau
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
package.yml@409bfff33f7f1318632a301b584fecff4ae4093a -
Trigger Event:
push
-
Statement type: