Skip to main content

Open Neural Network Exchange

Project description

ONNX Optimizer

PyPI version PyPI license PRs Welcome

Introduction

ONNX provides a C++ library for performing arbitrary optimizations on ONNX models, as well as a growing list of prepackaged optimization passes.

The primary motivation is to share work between the many ONNX backend implementations. Not all possible optimizations can be directly implemented on ONNX graphs - some will need additional backend-specific information - but many can, and our aim is to provide all such passes along with ONNX so that they can be re-used with a single function call.

You may be interested in invoking the provided passes, or in implementing new ones (or both).

Installation

You can install onnxoptimizer from PyPI:

pip3 install onnxoptimizer

Note that you may need to upgrade your pip first if you have trouble:

pip3 install -U pip

If you want to build from source:

git clone --recursive https://github.com/onnx/optimizer onnxoptimizer
cd onnxoptimizer
pip3 install -e .

Note that you need to install protobuf before building from source.

Command-line API

Now you can use command-line api in terminal instead of python script.

python -m onnxoptimizer input_model.onnx output_model.onnx

Arguments list is following:

# python3 -m onnxoptimizer -h                                 
usage: python -m onnxoptimizer input_model.onnx output_model.onnx 

onnxoptimizer command-line api

optional arguments:
  -h, --help            show this help message and exit
  --print_all_passes    print all available passes
  --print_fuse_elimination_passes
                        print all fuse and elimination passes
  -p [PASSES ...], --passes [PASSES ...]
                        list of optimization passes name, if no set, fuse_and_elimination_passes will be used
  --fixed_point         fixed point

Roadmap

  • More built-in pass
  • Separate graph rewriting and constant folding (or a pure graph rewriting mode, see issue #9 for the details)

Relevant tools

  • onnx-simplifier: A handy and popular tool based on onnxoptimizer

  • convertmodel.com: onnx optimizer compiled as WebAssembly so that it can be used out-of-the-box

Code of Conduct

ONNX Open Source Code of Conduct

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

onnxoptimizer-0.3.11.tar.gz (18.5 MB view hashes)

Uploaded Source

Built Distributions

onnxoptimizer-0.3.11-cp311-cp311-win_amd64.whl (381.3 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

onnxoptimizer-0.3.11-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (678.4 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

onnxoptimizer-0.3.11-cp311-cp311-macosx_10_15_x86_64.whl (577.8 kB view hashes)

Uploaded CPython 3.11 macOS 10.15+ x86-64

onnxoptimizer-0.3.11-cp311-cp311-macosx_10_15_universal2.whl (1.0 MB view hashes)

Uploaded CPython 3.11 macOS 10.15+ universal2 (ARM64, x86-64)

onnxoptimizer-0.3.11-cp310-cp310-win_amd64.whl (381.3 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

onnxoptimizer-0.3.11-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (678.4 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

onnxoptimizer-0.3.11-cp310-cp310-macosx_10_15_x86_64.whl (577.8 kB view hashes)

Uploaded CPython 3.10 macOS 10.15+ x86-64

onnxoptimizer-0.3.11-cp310-cp310-macosx_10_15_universal2.whl (1.0 MB view hashes)

Uploaded CPython 3.10 macOS 10.15+ universal2 (ARM64, x86-64)

onnxoptimizer-0.3.11-cp39-cp39-win_amd64.whl (380.9 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

onnxoptimizer-0.3.11-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (678.7 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

onnxoptimizer-0.3.11-cp39-cp39-macosx_10_15_x86_64.whl (578.0 kB view hashes)

Uploaded CPython 3.9 macOS 10.15+ x86-64

onnxoptimizer-0.3.11-cp39-cp39-macosx_10_15_universal2.whl (1.0 MB view hashes)

Uploaded CPython 3.9 macOS 10.15+ universal2 (ARM64, x86-64)

onnxoptimizer-0.3.11-cp38-cp38-win_amd64.whl (381.2 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

onnxoptimizer-0.3.11-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (678.5 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

onnxoptimizer-0.3.11-cp38-cp38-macosx_10_15_x86_64.whl (577.7 kB view hashes)

Uploaded CPython 3.8 macOS 10.15+ x86-64

onnxoptimizer-0.3.11-cp38-cp38-macosx_10_15_universal2.whl (1.0 MB view hashes)

Uploaded CPython 3.8 macOS 10.15+ universal2 (ARM64, x86-64)

onnxoptimizer-0.3.11-cp37-cp37m-win_amd64.whl (381.2 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

onnxoptimizer-0.3.11-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (679.4 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

onnxoptimizer-0.3.11-cp37-cp37m-macosx_10_15_x86_64.whl (577.0 kB view hashes)

Uploaded CPython 3.7m macOS 10.15+ x86-64

Supported by

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