Skip to content

joker-star-l/optimizer

This branch is up to date with onnx/optimizer:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

b3a4611 · Mar 3, 2024
Mar 12, 2023
Jun 29, 2022
Jun 28, 2022
Nov 2, 2023
Mar 3, 2024
Jan 17, 2021
Feb 21, 2021
Nov 8, 2020
Aug 19, 2022
Feb 9, 2023
Jan 17, 2021
May 4, 2022
Jan 30, 2023
Mar 3, 2024
Jan 17, 2021
Mar 12, 2023

Repository files navigation

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

About

Actively maintained ONNX Optimizer

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 49.6%
  • Python 48.1%
  • CMake 2.1%
  • C 0.2%