--- id: onnxoptimizer version: "0.4.2" license: Apache-2.0 license_treatment: permissive maintenance: active --- # onnxoptimizer — ONNX Optimizer License: permissive · Maintenance: active · Downloads: 413.1K/mo ## What it is and what it does ONNX Optimizer is a C++ library with Python bindings that applies graph-level transformations to ONNX neural network models. It provides a set of prepackaged optimization passes—such as operator fusion and constant elimination—designed to be reusable across different ONNX backend implementations. The library aims to reduce duplication of optimization work by centralizing common transformations that can be expressed at the graph level without backend-specific knowledge. You use it by loading an ONNX model, calling the optimizer with your chosen passes (or letting it apply the default fuse-and-elimination set), and saving the result. It also exposes a command-line interface for batch optimization. The package depends only on onnx and targets modern Python versions, with prebuilt wheels for common platforms. Use it for: - Reduce model size and inference latency by fusing adjacent operators into single kernels before deployment. - Apply constant folding to precompute static subgraphs and eliminate redundant computations at runtime. - Standardize model optimization across multiple ONNX backend implementations without reimplementing passes. - Batch-optimize a collection of ONNX models via command-line without writing Python scripts. - Prepare models for edge deployment by applying graph-level optimizations before quantization or pruning. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Applies graph-level optimizations to ONNX models, including a library of prepackaged passes for common transformations like operator fusion and constant elimination. Yes, if you work with ONNX models and want to reduce inference cost. The package is actively maintained, has no known vulnerabilities, uses a permissive license, and offers both a Python API and command-line interface. Install friction is moderate due to compiled wheels, but prebuilt binaries for current Python versions mitigate that. Suitable for model optimization pipelines in production or research. ## Install pip install onnxoptimizer uv add onnxoptimizer poetry add onnxoptimizer ## Installing onnxoptimizer Before you install: Medium install friction due to compiled wheels; prebuilt binaries available for current Python versions on macOS, Linux, and Windows. Actively maintained with recent releases and no known vulnerabilities. License in practice: Licensed under Apache-2.0 (permissive), allowing commercial use, modification, and redistribution with minimal restrictions. Quickstart: pip install onnxoptimizer import onnx import onnxoptimizer model = onnx.load('model.onnx') optimized = onnxoptimizer.optimize(model) onnx.save(optimized, 'optimized_model.onnx') Requires Python 3.10 or later; onnx must be installed as a runtime dependency. Verify before relying: - Which specific optimization passes are included in the prepackaged set beyond fusion and elimination. - Performance impact (latency/throughput gains) from applying these optimizations on typical models. - Whether custom optimization passes can be implemented and registered by users. ## Package facts - License: Apache-2.0 (permissive) - Python support: supports_current - Install friction: medium - Maintenance: active - Downloads: 413.1K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags onnx model optimization, onnx graph optimization passes, onnx operator fusion, onnx model compression, onnx inference optimization, onnx constant folding, neural network model optimization, model-optimization, onnx, graph-rewriting [View on SkillFed](https://skillfed.io/packages/onnxoptimizer) · [View on PyPI](https://pypi.org/project/onnxoptimizer/)