Registry / ai-ml / sne4onnx

sne4onnx

JSON →
library2.0.1pypypiunverified

A lightweight tool for extracting subgraphs (model slicing) from ONNX models. Useful when onnx-simplifier exceeds the 2GB Protocol Buffers file size limit, or to split models into arbitrary sizes. Current version 2.0.1, released June 2024. Development is active.

pip install sne4onnx
INSTALL
IMPORT
SIG · SNE4ONNX
S
sne4onnx
ai-mlpythonv2.0.1
Install
1.5s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.0.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.5s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

sne4onnx
from sne4onnx import sne4onnx
import sne4onnx

Extract a subgraph from an ONNX model by specifying input and output operation names.

import onnx from sne4onnx import extraction # Load an ONNX model model = onnx.load('model.onnx') # Define input and output operation names for the subgraph input_names = ['input'] # name of the input tensor or node output_names = ['output'] # name of the output tensor or node # Extract the subgraph new_model = extraction(model, input_names, output_names) # Save the extracted model onnx.save(new_model, 'extracted.onnx')
sne4onnx --version
Debug
Known issues
breakingIn version 2.0.0, dependency on `onnx_graphsurgeon` was removed. Code that relied on internals of `onnx_graphsurgeon` or used sne4onnx together with it may break.
fix
Update to v2.0.0+ and ensure no usage of `onnx_graphsurgeon` inside sne4onnx (it is no longer a dependency).
affects: <2.0.0
gotchaThe extraction function expects operation (node) names, not tensor names. Providing tensor names may silently fail or produce unexpected subgraphs.
fix
Use node names (e.g., from model.graph.node[i].name) as input/output_op_names. Inspect the model's graph nodes to find correct names.
affects: all
gotchaWhen using external data (large models with external data files), the library may corrupt the model if shape inference is run. Version 1.0.15 fixed this, but if you manually call `onnx.shape_inference.infer_shapes()` before extraction, you may encounter issues.
fix
Avoid calling `onnx.shape_inference.infer_shapes()` on models with external data before extraction. Let sne4onnx handle it.
affects: >=1.0.15
gotchaThe CLI `sne4onnx` arguments changed between versions. Short form parameters were added in v1.0.10 but long form (`--input_onnx_file_path`) may still be used. In v2.0.0, the CLI remains similar but ensure you use the correct syntax.
fix
Use `sne4onnx -h` to see current CLI arguments. Prefer long-form options for scripts to avoid ambiguity.
affects: all
Upgrade
Version history
2.0.1latest on PyPI · released Feb 24, 2026
Audit
Dependencies
onnxrequiredCore dependency for loading, manipulating, and saving ONNX models
Agent activity
16 hits · last 30 days
node
14
OpenAI (training)
1
Resources
sne4onnx — pip install sne4onnx · libregistry