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
muslpy 3.10–3.920 runs
build_error
glibcpy 3.10–3.920 runs
installs and imports cleanly · install 6.7s · import 0.574s · 190MB
193MB installed
● package 193MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
generate
✓ from sng4onnx import generate
The primary function for processing ONNX models.
This quickstart demonstrates how to use `sng4onnx` to process an ONNX model. It begins by programmatically creating a simple ONNX model, then passes it to the `generate` function to automatically assign operation names. Finally, it saves and verifies the processed model.
import onnx
from onnx import helper, TensorProto
import numpy as np
from sng4onnx import generate
import os
# 1. Create a dummy ONNX model for demonstration
def create_dummy_onnx(path):
# Define graph inputs
X = helper.make_tensor_value_info('X', TensorProto.FLOAT, [1, 2, 3])
Y = helper.make_tensor_value_info('Y', TensorProto.FLOAT, [1, 2, 3])
# Define graph outputs
Z = helper.make_tensor_value_info('Z', TensorProto.FLOAT, [1, 2, 3])
# Create a node (Mul operator)
node_def = helper.make_node(
'Add',
['X', 'Y'],
['Z'],
name='MyAddOperation' # Can be empty in an 'old format' model
)
# Create the graph
graph_def = helper.make_graph(
[node_def],
'simple_graph',
[X, Y],
[Z]
)
# Create the model
model_def = helper.make_model(graph_def, producer_name='dummy-model')
# Save the model
onnx.save(model_def, path)
input_onnx_path = 'input_model.onnx'
output_onnx_path = 'output_model_renamed.onnx'
create_dummy_onnx(input_onnx_path)
# 2. Use sng4onnx to generate/assign OP names
print(f"Processing {input_onnx_path}...")
renamed_model = generate(
input_onnx_file_path=input_onnx_path,
output_onnx_file_path=output_onnx_path,
non_verbose=False
)
# 3. Verify the output (optional)
if os.path.exists(output_onnx_path):
print(f"Successfully generated {output_onnx_path}")
loaded_model = onnx.load(output_onnx_path)
print(f"Nodes in renamed model: {[node.name for node in loaded_model.graph.node]}")
else:
print("Error: Output model not found.")
# Clean up dummy files
os.remove(input_onnx_path)
os.remove(output_onnx_path)
sng4onnx --version
Upgrade
Version history
2.0.1latest on PyPI · released Feb 24, 2026
Audit
Dependencies
onnxrequiredCore dependency for ONNX model manipulation.