Skip to main content

An Open Neural Network Exchange (ONNX) Optimization and Transformation Tool.

Project description

ONNXifier

English | 中文

A simple tool to convert any IR format to ONNX file.

Checked with pyright

Framework Status
OpenVINO
ONNXRuntime
TensorRT 🚧
TensorRT-LLM 🚧
  • ✅: well supported
  • 🪛: partially supported
  • 🚧: developing

Usage

  1. Install from PyPI
pip install onnxifier
  1. Convert IR using CLI
onnxify model.xml
usage: onnxify input_model.onnx [output_model.onnx]

onnxify command-line api

options:
  -h, --help            show this help message and exit
  --install-completion [{bash,pwsh}]
                        install shell completion for the specified shell and
                        exit.
  -a [ACTIVATE ...], --activate [ACTIVATE ...]
                        select passes to be activated, activate L1, L2 and L3
                        passes if not set.
  -r [REMOVE ...], --remove [REMOVE ...]
                        specify passes to be removed from activated passes.
  -n, --no-passes       do not run any optimizing passes, just convert the
                        model
  --print [PRINT]       print the name of all optimizing passes
  --format {protobuf,textproto,json,onnxtxt}
                        onnx file format
  -s, --infer-shapes    infer model shapes
  -c CONFIG_FILE, --config-file CONFIG_FILE
                        specify a json-format config file for passes
  -u, --uncheck         no checking output model
  --check               check optimized model with random inputs
  -d, --dry-run         only run passes without saving the output model
  --checker-backend {onnx,openvino,onnxruntime}
                        backend for accuracy checking, defaults to onnxruntime
  -v OPSET_VERSION, --opset-version OPSET_VERSION
                        target opset version, defaults to 20
  -vv [{DEBUG,INFO,WARNING,ERROR,CRITICAL}], --log-level [{DEBUG,INFO,WARNING,ERROR,CRITICAL}]
                        specify the level of log messages to be printed,
                        defaults to INFO
  -R, --recursive       recursively optimize nested functions
  --nodes [NODES ...]   specify a set of node names to apply passes only on
                        these nodes

To print pass information:

onnxify --print all
onnxify --print fuse_swish
onnxify --print l1

Shell Completion

onnxify provides tab-completion for Bash and PowerShell to help you quickly select pass names and options.

After installing onnxifier from PyPI, run the built-in installer once for your shell:

Bash

onnxify --install-completion bash
source ~/.bashrc

PowerShell

onnxify --install-completion pwsh
. $PROFILE

The installer is idempotent — running it again will not duplicate entries in your profile.

Once enabled, you can use Tab to complete pass names after -a / -r / --print, for example:

# Complete a single pass
onnxify model.onnx -a ins<TAB>
# → inspect_sparsity_ratio inspect_weights_distribution insert_conv_before_act_shave

# Complete multiple space-separated passes
onnxify model.onnx -a infer_shape fold_const<TAB>
# → fold_constant

# Complete comma-separated passes
onnxify model.onnx -a fuse_gelu,ins<TAB>
# → fuse_gelu,inspect_sparsity_ratio ...

# Complete --print arguments
onnxify --print l<TAB>
# → l1 l2 l3

TODO

  • [OV] Add Loop support.
  • [OV] Add NMS support.
  • [OV] Add If support.
  • [ONNX] Support to optimize If.

Contribute

  1. pyright type checking
pip install -U pyright
pyright onnxifier
  1. mypy type checking
pip install -U mypy
mypy onnxifier --disable-error-code=import-untyped --disable-error=override --disable-error=call-overload
  1. pre-commit checking
pip install -U pre-commit
pre-commit run --all-files

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

onnxifier-2.1.1.tar.gz (374.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

onnxifier-2.1.1-py3-none-any.whl (322.9 kB view details)

Uploaded Python 3

File details

Details for the file onnxifier-2.1.1.tar.gz.

File metadata

  • Download URL: onnxifier-2.1.1.tar.gz
  • Upload date:
  • Size: 374.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.33.1

File hashes

Hashes for onnxifier-2.1.1.tar.gz
Algorithm Hash digest
SHA256 e9adfb58ce887e2e2e1ea589fb6ca695adbb1cdba20cc1362b12f01be589d7bc
MD5 1073d3eab9b2d6e9575e7a542545dd44
BLAKE2b-256 69c58246dbc77f47c4c43cd94378e5d3b54063e90b870037849beff3e597f65c

See more details on using hashes here.

File details

Details for the file onnxifier-2.1.1-py3-none-any.whl.

File metadata

  • Download URL: onnxifier-2.1.1-py3-none-any.whl
  • Upload date:
  • Size: 322.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.33.1

File hashes

Hashes for onnxifier-2.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 65ac447a98a037ddc0ed748df71cacc96cc57520211065aca04db8b750d8e795
MD5 85f14e3d95d4a805fc253a3b34b88a5e
BLAKE2b-256 8efe7ef3cc3545694e914c713d9aafe31722b2a35b1ef73ff3b1da49e989b65f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page