Skip to content
Back to skills

Python Simplification

ASecurity

CLI and Python API workflows for simplifying ONNX models.

  • 247 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 8, 2026
toolspythonrustbashapibackend

Works with

  • cli
  • api

Security analysis

A100/100

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

Scanned September 8, 2026

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

Installs into .claude/skills of the current project.

Are you the author of Python Simplification?

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

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

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: "python-simplification"
description: "CLI and Python API workflows for simplifying ONNX models."
disable-model-invocation: true
metadata:
  disco-role: operating
license: Apache 2.0
---

# Python Simplification

Use this sub-skill when the task is to simplify an ONNX model from a file or an
`onnx.ModelProto` with `onnxsim.simplify` or the `onnxsim` CLI.

## Covers

- Static and dynamic input shapes.
- Correctness checking with `check_n`, `check_rtol`, `check_atol`, and
  `input_fill`.
- Input data injection, optimizer skipping, and constant-folding control.
- Provider selection, including the CUDA shortcut behavior.
- External-data output and large tensor warnings.
- Target opset conversion and local function inlining.
- Custom operator schema import for validation.
- Graph diff output after simplification.

## Do not use this sub-skill for

- Custom graph rewriter design, function-rule authoring, or profiling / model
  metrics depth. Hand those off to the sibling `advanced-graph-control`
  sub-skill (`../advanced-graph-control/SKILL.md`).
- Build, install, wheel, C API, Rust, WASM, or packaging troubleshooting.
  Hand those off to the sibling `bindings-and-packaging` sub-skill
  (`../bindings-and-packaging/SKILL.md`).

## Read first

- [API and CLI summary](references/api-and-cli.md)
- [Workflow recipes](references/workflows.md)
- [Troubleshooting](references/troubleshooting.md)

## Standard flow

1. Identify whether the caller has an ONNX file or an in-memory `ModelProto`.
2. Decide how shapes and validation inputs will be supplied:
   `overwrite_input_shapes`, `test_input_shapes`, `input_data`, or
   `input_fill`.
3. Choose optimizer and folding controls:
   `skip_optimization`, `skip_constant_folding`, `skip_shape_inference`,
   `skip_fuse_bn`, `mutable_initializer`, `initializers_as_constants`, and
   `inline_functions`.
4. Decide backend and opset behavior: `providers`, `--cuda`, and
   `target_opset_version`.
5. Run simplification, then validate with `check_n` and a direct round-trip
   comparison when needed.
6. Save external data or print graph diff only when asked.

## Helper script

Use [`scripts/simplify_tiny_model.py`](scripts/simplify_tiny_model.py) for a
safe smoke run:

```bash
python scripts/simplify_tiny_model.py --help
python scripts/simplify_tiny_model.py --check-n 3 --input-fill arange --print-summary
python scripts/simplify_tiny_model.py --output tiny-simplified.onnx
```

The script builds a tiny synthetic model, simplifies it with the public API,
validates the result, and never downloads models.

## Common outcomes

- File CLI calls return a simplified ONNX path and, when requested, graph diff
  output.
- Python API calls return `(model_simp, check)`; treat `check=False` as a stop
  signal unless the caller explicitly wants an exploratory run.
- If `providers` is omitted, folding stays on CPU.
- For a fast smoke run, use the bundled helper script with `--print-summary`.

## Routing notes

- The sub-skill accepts the core simplification surface only. For custom
  rewriters and profiling / metrics depth, move to the sibling
  `advanced-graph-control` sub-skill.
- For packaging or backend installation problems, move to the sibling
  `bindings-and-packaging` sub-skill.
- If a provider request fails, consult the troubleshooting table before changing
  the model.

Files in this skill

  • SKILL.md3.3 KB
  • references/api-and-cli.md5.1 KB
  • references/troubleshooting.md3.9 KB
  • references/workflows.md5.7 KB
  • scripts/simplify_tiny_model.py6 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.