ONNX support in deep learning frameworks

ONNX is an open format created to represent machine learning models. The ONNX format is frequently updated with new operators that are present in state-of-the-art models.

Most of the frameworks for training, compiling and optimizing deep learning algorithms support ONNX format. It allows conversion of models from one representation to another.

The kenning.core.onnxconversion.ONNXConversion class provides an API for writing compatibility tests between ONNX and deep learning frameworks.

It requires implementing:

  • a method for ONNX model import for a given framework,

  • a method for ONNX model export from a given framework,

  • a list of models implemented in a given framework, where each model is exported to ONNX, and then imported back to the framework.

The ONNXConversion class implements a method for model conversion. It catches exceptions and any issues in the import/export methods, and provides a report on conversion status per model.

See the TensorFlowONNXConversion class for an example of API usage.

ONNX support grid in deep learning frameworks

ONNX conversion support grid

Note

This section was generated using:

python -m kenning.scenarios.onnx_conversion \
    build/models-directory \
    build/onnx-support.md \
    --converters-list \
        kenning.onnxconverters.mxnet.MXNetONNXConversion \
        kenning.onnxconverters.pytorch.PyTorchONNXConversion \
        kenning.onnxconverters.tensorflow.TensorFlowONNXConversion
Table 1 ONNX conversion support grid

Model Name

mxnet (ver. 1.9.1)

pytorch (ver. 1.13.1+cu117)

tensorflow (ver. 2.9.3)

DenseNet201

supported / supported

supported / unsupported

supported / ERROR

MobileNetV2

supported / ERROR

supported / unsupported

supported / ERROR

ResNet50

supported / supported

supported / unsupported

supported / ERROR

DeepLabV3 ResNet50

ERROR / unverified

supported / unsupported

Not provided / Not provided

Faster R-CNN ResNet50 FPN

supported / ERROR

supported / unsupported

Not provided / Not provided

Mask R-CNN

supported / ERROR

supported / unsupported

Not provided / Not provided

RetinaNet ResNet50 FPN

Not provided / Not provided

supported / unsupported

Not provided / Not provided

Table 1 table shows ONNX conversion support for several of the popular models across various deep learning frameworks. Each row represents a different deep learning model. Each column represents a different deep learning framework. Each cell lists an export to ONNX and import from ONNX support status for a given model and framework.

Firstly, the model is downloaded for a given framework. Secondly, the model is converted to ONNX. Lastly, the ONNX model is converted back to the framework’s format.

The values in cells are in <export support> / <import support> format.

Possible values are:

  • supported if export or import was successful,

  • unsupported if export or import is not implemented for a given framework,

  • ERROR if export or import ended up with error for a given framework,

  • unverified if import could not be tested due to lack of support for export or an error during export.

  • Not provided if the model was not provided for the framework.


Last update: 2023-03-28