onnxsim/onnxsim

Simplify your onnx model

What it solves

ONNX Simplifier cleans up overcomplicated ONNX computation graphs by removing redundant operators and replacing them with constant outputs. It streamlines models so they run more efficiently and integrate cleanly with downstream compilers and runtime frameworks.

How it works

It runs an iterative loop of shape inference, graph optimization, and constant folding until the model stops changing. It evaluates constant parts of the graph, applies optimization passes, and infers tensor shapes—optionally running entirely in the browser via WebAssembly or through Python, C, and Rust bindings.

Who it’s for

Machine learning engineers and developers working with ONNX models who need to optimize, simplify, or convert models for deployment across diverse hardware targets and compiler stacks.

Highlights

  • Automatically folds constants and removes redundant graph nodes.
  • Supports shape inference, custom operators, and function inlining.
  • Can convert model opset versions on the fly.
  • Includes optional exports to MLIR, Core ML, TensorFlow Lite, and standalone archives like Safetensors or GGUF.
  • Offers zero-install web version, Python package, CLI, C API, and Rust wrapper.

Related

  • Project
  • Project
  • Project
  • Project
  • Project