Tensorflow Backend and Frontend for ONNX
Clone or download
chinhuang007 and tjingrant Fix python3 issue and disconnected nodes (#248)
In bias_add, the channel first check doesn't work in
python3, and inputs outputs name mismatch causes
disconnected nodes in graph. Add type check for
data_format[1] and underscore for inputs.

Also include test cases initially created in
Latest commit 2ae9223 Sep 13, 2018


Tensorflow Backend and Frontend for ONNX

Build Status

ONNX-Tensorflow API

ONNX-Tensorflow Op Coverage Status


Running an ONNX model using Tensorflow

Exporting a Tensorflow Model to ONNX

To install:

ONNX-TF requires ONNX (Open Neural Network Exchange) as an external dependency, for any issues related to ONNX installation, we refer our users to ONNX project repository for documentation and help. Notably, please ensure that protoc is available if you plan to install ONNX via pip.

The specific ONNX release version that we support in the master branch of ONNX-TF can be found here. This information about ONNX version requirement is automatically encoded in setup.py, therefore users needn't worry about ONNX version requirement when installing ONNX-TF.

To install the latest version of ONNX-TF via pip, run pip install onnx-tf.

Because users often have their own preferences for which variant of Tensorflow to install (i.e., a GPU version instead of a CPU version), we do not explicitly require tensorflow in the installation script. It is therefore users' responsibility to ensure that the proper variant of Tensorflow is available to ONNX-TF. Moreoever, we require Tensorflow version >= 1.5.0.

To test:

For backend, run python -m unittest discover test.


In this example, we will define and run a Relu node and print the result. This example is available as a python script at example/relu.py .

from onnx_tf.backend import run_node
from onnx import helper

node_def = helper.make_node("Relu", ["X"], ["Y"])
output = run_node(node_def, [[-0.1, 0.1]])

The result is [ 0. 0.1]

Development Install:

  • Install ONNX master branch from source.
  • Install Tensorflow>=1.5.0.
  • Run git clone git@github.com:onnx/onnx-tensorflow.git && cd onnx-tensorflow.
  • Run pip install -e ..

Folder Structure:

  • onnx_tf main source code file.
  • test test files.

Code Standard:

  • Format code:
pip install yapf
yapf -rip --style="{based_on_style: google, indent_width: 2}" $FilePath$
  • Install pylint:
pip install pylint
wget -O /tmp/pylintrc https://raw.githubusercontent.com/tensorflow/tensorflow/master/tensorflow/tools/ci_build/pylintrc
  • Check format:
pylint --rcfile=/tmp/pylintrc myfile.py

Documentation Standard:


Test Help:



Arpith Jacob (IBM Research)

Tian Jin (IBM Research)

Gheorghe-Teodor Bercea (IBM Research)

Wenhao Hu (LeapMind)