onnx2tf

A tool for converting ONNX files to LiteRT/TFLite/TensorFlow, PyTorch native code (nn.Module), TorchScript (.pt), state_dict (.pt), Exported Program (.pt2), and

What is onnx2tf?

A tool for converting ONNX files to LiteRT/TFLite/TensorFlow, PyTorch native code (nn.Module), TorchScript (.pt), state_dict (.pt), Exported Program (.pt2), and Dynamo ONNX. It also supports direct conversion from LiteRT to PyTorch.

Overview of onnx2tf

What it is

onnx2tf is a tool for converting ONNX files to LiteRT/TFLite/TensorFlow, PyTorch native code (nn.Module), TorchScript (.pt), state_dict (.pt), Exported Program (.pt2), and Dynamo ONNX. It also supports direct conversion from LiteRT to PyTorch. The project is hosted on GitHub under the repository PINTO0309/onnx2tf. The README notes that users should consider using LiteRT Torch instead of onnx2tf, with links to https://github.com/google-ai-edge/litert-torch and https://github.com/google-ai-edge/ai-edge-quantizer. The tool provides two execution paths: tf_converter and flatbuffer_direct. The flatbuffer_direct path is the current default backend, described as faster and with a higher success rate for supported direct conversions. By default, the simplest conversion command outputs only a LiteRT model, but adding --flatbuffer_direct_output_saved_model also outputs a saved_model built from the LiteRT-side ModelIR. The tf_converter path supports a large number of ONNX operators, as listed in the README table. Operators are marked with :heavy_check_mark: for full support or :white_check_mark: for partial support. The tool is open source under the MIT license.

Key features

  • Converts ONNX files to multiple target formats: LiteRT/TFLite/TensorFlow, PyTorch native code (nn.Module), TorchScript (.pt), state_dict (.pt), Exported Program (.pt2), and Dynamo ONNX.
  • Supports direct conversion from LiteRT to PyTorch.
  • Provides two execution backends: tf_converter (legacy) and flatbuffer_direct (default, faster, higher success rate).
  • Supports a comprehensive list of ONNX operators, with most fully supported and some partially supported.
  • Can output a saved_model in addition to LiteRT model when using flatbuffer_direct with the appropriate flag.

Use cases

  • Converting ONNX models for deployment on edge devices using LiteRT/TFLite.
  • Porting ONNX models to PyTorch for further training or inference in PyTorch environments.
  • Generating TorchScript or state_dict files from ONNX for use in PyTorch workflows.
  • Converting models between different frameworks (ONNX to TensorFlow, ONNX to PyTorch, LiteRT to PyTorch).

Getting started

See the repository README for installation and usage instructions.

License and pricing

The project is licensed under the MIT License and is open source. No pricing information is stated.

Based on the project's public README and repository metadata.

Add this badge to your README

Featured on YunoDB Badge styles & help

Maintain this project? Show that it is featured on YunoDB.

Markdown[![Featured on YunoDB](https://yunodb.com/badge/pinto0309onnx2tf.svg)](https://yunodb.com/tools/pinto0309onnx2tf?utm_source=github&utm_medium=badge)
HTML<a href="https://yunodb.com/tools/pinto0309onnx2tf?utm_source=github&utm_medium=badge"><img src="https://yunodb.com/badge/pinto0309onnx2tf.svg" alt="Featured on YunoDB" height="20"></a>