Repolode
inisis

inisis/OnnxSlim

A Python toolkit that optimizes ONNX models by reducing operator count while keeping accuracy, aiming for faster inference.

Stars
521
Forks
44
Open issues
31
Last commit
4 days ago

What is it?

OnnxSlim slims down ONNX models by removing redundant operators, so the resulting graph is smaller and typically runs faster during inference. It can be used from the command line with a single `onnxslim input output` call, or from Python by passing a loaded model to `onnxslim.slim()` and saving the result.

The project is distributed on PyPI as `onnxslim` and can also be installed from source. Its README lists several open-source projects that have adopted it as part of their model export or optimization pipelines, including Ultralytics, Hugging Face Optimum, and transformers.js.

Key features

  • 01Reduces the number of operators in an ONNX graph while aiming to preserve accuracy.
  • 02Provides a command-line tool for quick model slimming.
  • 03Offers a Python API that takes a loaded ONNX model and returns an optimized one.
  • 04Installable from PyPI or directly from source.

Use cases

  • Reducing the size and operator count of an ONNX model before deploying it with ONNX Runtime.
  • Adding an optimization step to a model export pipeline built on PyTorch or similar frameworks.
  • Trimming models used in LLM or vision inference workloads.

Quick start

  1. 1

    Install the prebuilt package from PyPI

    pip install onnxslim
  2. 2

    Slim an ONNX model from the command line

    onnxslim your_onnx_model slimmed_onnx_model

Topics

FAQ

What is OnnxSlim?
A Python toolkit that optimizes ONNX models by reducing operator count while keeping accuracy, aiming for faster inference. OnnxSlim slims down ONNX models by removing redundant operators, so the resulting graph is smaller and typically runs faster during inference. It can be used from the command line with a single `onnxslim input output` call, or from Python by passing a loaded model to `onnxslim.slim()` and saving the result.
Is OnnxSlim free to use? What license does it have?
OnnxSlim is open source under the MIT license. Check the license terms before using it in commercial products.
Is OnnxSlim still maintained?
Actively maintained. The last commit to OnnxSlim was on Oct 16, 2026.
What can I use OnnxSlim for?
Reducing the size and operator count of an ONNX model before deploying it with ONNX Runtime. Adding an optimization step to a model export pipeline built on PyTorch or similar frameworks. Trimming models used in LLM or vision inference workloads.
How do I install OnnxSlim?
Install the prebuilt package from PyPI: pip install onnxslim Slim an ONNX model from the command line: onnxslim your_onnx_model slimmed_onnx_model
Where can I get OnnxSlim?
The source code and installation instructions are on GitHub: https://github.com/inisis/OnnxSlim

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects