• Stars
    star
    579
  • Rank 74,496 (Top 2 %)
  • Language
    C++
  • License
    Apache License 2.0
  • Created almost 4 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Actively maintained ONNX Optimizer

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

More Repositories

1

onnx

Open standard for machine learning interoperability
Python
16,640
star
2

models

A collection of pre-trained, state-of-the-art models in the ONNX format
Jupyter Notebook
7,054
star
3

tutorials

Tutorials for creating and using ONNX models
Jupyter Notebook
3,175
star
4

onnx-tensorrt

ONNX-TensorRT: TensorRT backend for ONNX
C++
2,769
star
5

tensorflow-onnx

Convert TensorFlow, Keras, Tensorflow.js and Tflite models to ONNX
Jupyter Notebook
2,224
star
6

onnx-tensorflow

Tensorflow Backend for ONNX
Python
1,238
star
7

onnxmltools

ONNXMLTools enables conversion of models to ONNX
Python
936
star
8

onnx-mlir

Representation and Reference Lowering of ONNX Models in MLIR Compiler Infrastructure
C++
686
star
9

sklearn-onnx

Convert scikit-learn models and pipelines to ONNX
Python
508
star
10

onnx-coreml

ONNX to Core ML Converter
Python
389
star
11

keras-onnx

Convert tf.keras/Keras models to ONNX
Python
379
star
12

onnx-caffe2

Caffe2 implementation of Open Neural Network Exchange (ONNX)
Python
168
star
13

onnx-docker

Dockerfiles and scripts for ONNX container images
Jupyter Notebook
129
star
14

onnx-mxnet

ONNX model format support for Apache MXNet
Python
96
star
15

turnkeyml

The AI insights toolchain
Python
45
star
16

onnx-r

R Interface to Open Neural Network Exchange (ONNX)
R
42
star
17

backend-scoreboard

Scoreboard for ONNX Backend Compatibility
Python
23
star
18

onnx.github.io

Code of the official webpage of onnx
HTML
22
star
19

steering-committee

Notes and artifacts from the ONNX steering committee
Jupyter Notebook
22
star
20

working-groups

Repository for ONNX working group artifacts
Jupyter Notebook
20
star
21

sigs

Repository for ONNX SIG artifacts
19
star
22

onnx-xla

XLA integration of Open Neural Network Exchange (ONNX)
C++
18
star
23

wheel-builder

Utils for building and publishing ONNX wheels
Shell
7
star
24

onnx-cntk

Python
6
star