--- id: onnxsim version: "0.7.3" license: MIT AND (Apache-2.0 OR BSD-2-Clause) license_treatment: permissive maintenance: active --- # onnxsim — Simplify your ONNX model License: permissive · Maintenance: active · Downloads: 543.0K/mo ## What it is and what it does ONNX Simplifier takes a compiled ONNX neural network model and reduces it by eliminating redundant operations through constant folding, shape inference, and graph optimization. It runs a fixed-point loop of these three techniques until the model stops changing, then optionally validates the result against the original on random inputs to ensure correctness. The package is used to shrink models exported from frameworks like PyTorch, making them faster to load and run while preserving numerical behavior. It handles both static and dynamic input shapes, supports custom operators (including TensorRT plugins), can inline local functions, simplify subgraphs, and convert between ONNX opset versions. It is available as a Python package with a CLI, a C API, a Rust wrapper, and a zero-install web version. Use it for: - Reduce the size of PyTorch models exported to ONNX before deployment to edge devices or inference servers. - Remove redundant reshape, transpose, and constant-computation nodes introduced during framework export. - Validate that a simplified ONNX model produces numerically equivalent outputs on random test inputs. - Upgrade or downgrade an ONNX model's opset version while cleaning up any redundant nodes the conversion introduces. - Simplify models containing custom operators like TensorRT plugins without manually moving them to a custom domain. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Simplifies ONNX neural network models by running constant folding, shape inference, and graph optimization passes to reduce redundant operators and produce smaller, faster models. Yes. The package is actively maintained, has no known vulnerabilities, uses permissive licenses, and solves a real problem in ONNX model deployment. Medium install friction is acceptable given the precompiled wheels for modern Python versions and multiple platforms. Install if you work with exported ONNX models and need to reduce their size or remove redundant operations. ## Install pip install onnxsim uv add onnxsim poetry add onnxsim ## Installing onnxsim Before you install: Medium install friction due to precompiled wheels for multiple Python versions and platforms (cp310–cp314, macOS arm64, Linux x86_64/aarch64, Windows). Active maintenance with a release 2 days ago and 4386 repository stars. License in practice: Dual-licensed under MIT and (Apache-2.0 OR BSD-2-Clause), both permissive. You may use, modify, and distribute freely under either license's terms. Quickstart: pip install onnxsim import onnx from onnxsim import simplify model = onnx.load('model.onnx') model_simp, check = simplify(model) assert check, "Simplified model validation failed" Requires Python >=3.10 and the onnx package (a runtime dependency). Verify before relying: - Whether onnxruntime is truly optional or recommended for performance; fact sheet notes it falls back to ONNX reference evaluator but does not quantify the performance difference. - Whether the web version and Node.js npm package share feature parity with the Python package or have limitations not mentioned in the excerpt. ## Package facts - License: MIT AND (Apache-2.0 OR BSD-2-Clause) (permissive) - Python support: supports_current - Install friction: medium - Maintenance: active - Downloads: 543.0K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags ONNX model simplification, constant folding neural networks, reduce ONNX model size, graph optimization ONNX, ONNX model compression, simplify deep learning models, ONNX inference optimization, model-optimization, onnx, deep-learning [View on SkillFed](https://skillfed.io/packages/onnxsim) · [View on PyPI](https://pypi.org/project/onnxsim/)