Skip to content
Back to skills

Onnxsim

ASecurity

"Repo skill for ONNX Simplifier: ONNX model simplification, graph

  • 247 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added September 8, 2026
devopspythonrustc++bashapibackend

Works with

  • cli
  • api

Security analysis

A96/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro scans all 20 files and shows the line behind each finding

Scanned September 8, 2026

npx -y skills add VectorSpaceLab/AREX-Skill --skill onnxsim --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Onnxsim?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Onnxsim
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vectorspacelab-onnxsim/badge)](https://www.skillsdirectory.com/skills/vectorspacelab-onnxsim)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: onnxsim
description: "Repo skill for ONNX Simplifier: ONNX model simplification, graph
  rewriting, metrics, profiling, packaging, and bindings."
disable-model-invocation: true
metadata:
  disco-role: operating
license: Apache 2.0
---

# ONNX Simplifier (`onnxsim`)

Use this repo skill when a task involves ONNX Simplifier / `onnxsim`: simplifying
exported ONNX graphs, validating simplified models, controlling optimizer and
constant-folding behavior, using custom rewrite rules, inspecting model metrics
or profile traces, or maintaining the package's Python/C++/Rust/WASM bindings.

## Start here

- Read [package overview](references/package-overview.md) for package identity,
  install commands, backend model, and route selection.
- Read [cross-cutting troubleshooting](references/troubleshooting.md) when the
  failure surface is unclear.
- Read [repository provenance](references/repo-provenance.md) before deciding
  whether this skill is current for a checkout or before running a refresh.
- `references/repo-routing-metadata.json` is structured metadata for managed
  repo-skill import; do not hand-edit router Markdown.

## Minimal installed-package check

```bash
python -m pip install -U onnxsim
python -c "import onnxsim; print(onnxsim.__version__)"
onnxsim --help
onnxsim --list-default-optimizers
```

If an environment may be broken, run the bundled checker from this skill root:

```bash
python scripts/check_onnxsim_env.py --help
python scripts/check_onnxsim_env.py --smoke --json
python scripts/check_onnxsim_env.py --providers CPUExecutionProvider --json
```

The checker imports `onnxsim`, verifies the compiled extension, reports optional
ONNX Runtime providers, probes the CLI optimizer list, and can run a tiny
in-memory simplification smoke.

## Route by task

| User task | Read |
| --- | --- |
| Simplify an ONNX file with the CLI, set input shapes, run correctness checks, choose CPU/CUDA providers, save external data, convert target opset, or use custom operator schemas | [`sub-skills/python-simplification/SKILL.md`](sub-skills/python-simplification/SKILL.md) |
| Call `onnxsim.simplify` from Python with `ModelProto` objects, inspect the full API signature, map CLI flags to parameters, or recover from model/check/provider errors | [`sub-skills/python-simplification/SKILL.md`](sub-skills/python-simplification/SKILL.md) |
| Author Python `custom_rewriter` callbacks, pure-data `FunctionProto` rewrite rules, or custom schema import logic | [`sub-skills/advanced-graph-control/SKILL.md`](sub-skills/advanced-graph-control/SKILL.md) |
| Use `ModelInfo`, MACs/FLOPs/memory metrics, `annotate_metadata`, `diff_graphs`, `--graph-diff`, `profile`, `ort_profile`, or merged ONNX Runtime traces | [`sub-skills/advanced-graph-control/SKILL.md`](sub-skills/advanced-graph-control/SKILL.md) |
| Install/build from source, diagnose missing submodules/nanobind/protobuf/CMake, build the C API, use Rust crates, build WASM/npm/web demo, or check release versions | [`sub-skills/bindings-and-packaging/SKILL.md`](sub-skills/bindings-and-packaging/SKILL.md) |

## Key operating facts

- `onnxsim.simplify(model, ...)` accepts an ONNX file path or an in-memory
  `onnx.ModelProto` and returns `(simplified_model, check_ok)`.
- CPU constant folding is the default. `onnxruntime` is optional for the Python
  package; without it, onnxsim can use ONNX's reference evaluator.
- Non-CPU execution providers require ONNX Runtime with the matching provider
  build. `--cuda` means `--providers CUDAExecutionProvider CPUExecutionProvider`.
- Custom operator schemas registered in Python ONNX are imported into onnxsim's
  registry by default; CLI users can disable that with `--skip-schema-import`.
- Python `custom_rewriter` callbacks and pure-data `function_rewrite_rules` are
  mutually exclusive in one `simplify()` call.
- FunctionProto rewrite rules are portable to C/Rust bindings because they are
  protobuf data matched in the C++ core.
- `ModelInfo` and `annotate_metadata` are static inspection tools; unknown shapes
  or missing optional `sympy` can make metrics best-effort or symbolic.
- The Python wheel/editable build uses `-DONNXSIM_BUILTIN_ORT=OFF`; it does not
  compile vendored ONNX Runtime C++. ONNX Runtime C++ builds belong to standalone
  CMake/C API/Rust native-library/default-WASM paths.

## Bundled scripts

- [`scripts/check_onnxsim_env.py`](scripts/check_onnxsim_env.py): installed
  package, provider, CLI, and tiny simplification smoke checker.
- [`sub-skills/python-simplification/scripts/simplify_tiny_model.py`](sub-skills/python-simplification/scripts/simplify_tiny_model.py): safe tiny model simplification helper.
- [`sub-skills/advanced-graph-control/scripts/function_rule_smoke.py`](sub-skills/advanced-graph-control/scripts/function_rule_smoke.py): pure-data FunctionProto rewrite smoke.
- [`sub-skills/advanced-graph-control/scripts/model_metrics_smoke.py`](sub-skills/advanced-graph-control/scripts/model_metrics_smoke.py): metrics, metadata, and graph-diff smoke.
- [`sub-skills/bindings-and-packaging/scripts/check_version_sync.py`](sub-skills/bindings-and-packaging/scripts/check_version_sync.py): read-only version metadata checker for a user-supplied source tree.

## Safe defaults

- Prefer a released wheel plus `onnxsim --help` / `--list-default-optimizers` for
  ordinary use.
- Use `check_n`, deterministic `input_fill`, and explicit `test_input_shapes`
  when correctness matters.
- Start optional provider and build investigations with help/version/smoke
  checks; do not install heavy CUDA/QNN/TVM/Halide/model-export stacks or launch
  long WASM/Rust/native builds unless the user explicitly selected that path.
- Treat `check_ok=False`, provider validation errors, and schema validation
  errors as blockers for deployment-style tasks until the user accepts the risk
  or the issue is fixed.

Files in this skill

  • SKILL.md5.7 KB
  • references/package-overview.md4.3 KB
  • references/repo-provenance.md2.1 KB
  • references/repo-routing-metadata.json520 B
  • references/troubleshooting.md3.8 KB
  • scripts/check_onnxsim_env.py6.9 KB
  • sub-skills/advanced-graph-control/SKILL.md6.4 KB
  • sub-skills/advanced-graph-control/references/metrics-and-profiling.md10.3 KB
  • sub-skills/advanced-graph-control/references/rewriters-and-rules.md9.6 KB
  • sub-skills/advanced-graph-control/references/troubleshooting.md11 KB
  • sub-skills/advanced-graph-control/scripts/function_rule_smoke.py5.7 KB
  • sub-skills/advanced-graph-control/scripts/model_metrics_smoke.py7.4 KB
  • sub-skills/bindings-and-packaging/SKILL.md7.7 KB
  • sub-skills/bindings-and-packaging/references/build-and-bindings.md14.1 KB
  • sub-skills/bindings-and-packaging/references/troubleshooting.md9.9 KB
  • sub-skills/bindings-and-packaging/references/wasm-and-web.md8.9 KB
  • sub-skills/bindings-and-packaging/scripts/check_version_sync.py6 KB
  • sub-skills/python-simplification/SKILL.md3.3 KB
  • sub-skills/python-simplification/references/api-and-cli.md5.1 KB
  • sub-skills/python-simplification/references/troubleshooting.md3.9 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.