A tool to legalize TFLite FlatBuffer to TOSA MLIR.
Project description
TOSA converter for TFLite
A tool to legalize TFLite FlatBuffer to TOSA MLIR Bytecode or Text.
TOSA Converter for TFLite is currently in the experimental development phase. As such, it may contain bugs or incomplete features. We appreciate your feedback and patience as we continue to improve the tool.
Usage
Python API
from tosa_converter_for_tflite import (
tflite_flatbuffer_to_tosa_mlir,
TosaConverterDebugInfo,
TosaConverterOutputFormat,
)
# default (bytecode) output
tflite_flatbuffer_to_tosa_mlir("model_input.tflite", "model_output.tosa.mlirbc")
# textual MLIR output (locations are off by default)
tflite_flatbuffer_to_tosa_mlir(
"model_input.tflite",
"model_output.mlir",
TosaConverterOutputFormat.Text
)
# textual MLIR output with explicit location annotations (debug info)
tflite_flatbuffer_to_tosa_mlir(
"model_input.tflite",
"model_output_with_locs.mlir",
TosaConverterOutputFormat.Text,
TosaConverterDebugInfo.Enable
)
Command-line Interface (CLI)
The tosa-converter-for-tflite CLI provides a simple way to convert .tflite models
into TOSA MLIR(bytecode or text). It supports both file-based and stream-based workflows
for easy integration into toolchains or pipelines.
Usage Examples
Convert a .tflite file to a TOSA bytecode file(default):
tosa-converter-for-tflite model.tflite --bytecode -o out.tosa.mlirbc
Version Info
--version prints the converter version along with the TensorFlow and LLVM commit hashes:
TOSA Converter for TFLite version: 2026.02.0
TensorFlow commit: <tf_commit_hash>
LLVM commit: <llvm_commit_hash>
Read the model from file and write textual TOSA MLIR to file
tosa-converter-for-tflite model.tflite --text -o out.mlir
Enable per-operation location annotations in textual MLIR
tosa-converter-for-tflite model.tflite --text --emit-debug-info -o out_with_locs.mlir
Read the model from a file and write textual TOSA MLIR to stdout
tosa-converter-for-tflite model.tflite --text
Stream the model from stdin and write bytecode to file
cat model.tflite | tosa-converter-for-tflite --bytecode -o out.tosa.mlirbc
Fully stream the model from stdin and write textual MLIR to stdout
cat model.tflite | tosa-converter-for-tflite --text
Debug info and locations
Textual MLIR can include per-operation location annotations (e.g., loc(#loc3)).
These annotations are disabled by default; enable them with
TosaConverterDebugInfo.Enable in the Python API or --emit-debug-info in the
CLI. They are useful for debugging, but can significantly increase output
size. If you run into memory or storage issues, keep debug info disabled.
When writing to an in-memory Python BinaryIO stream, the converter buffers the
entire output before writing it to the stream. For large models (especially with
debug info enabled), prefer writing to a file to avoid excessive peak memory use.
Supported Platforms
This tool supports Linux(r) and Windows(r) on x86_64 architectures. Support for Linux(r) on AArch64 is experimental.
Build Requirements
Before you build the converter, ensure you have the following tools installed and on your PATH.
Linux (Ubuntu)
| Tool | Purpose | Version |
|---|---|---|
| Bazel | build | v7.4.1 |
| Clang | build | >= v17 |
| Python | build & runtime | >= v3.10 |
Windows (x86_64)
| Tool | Purpose | Version |
|---|---|---|
| Bazel | build | 7.4.1 |
| LLVM (Clang-CL) | build | 20.1.0 |
| MSYS2 | shell & tooling | 3.6.3-2 with Pacman 20.1.0 and bash.exe |
| Python | build & runtime | ≥3.10 |
| Visual Studio 2022 Professional (C++ Desktop Dev Tools) | build & debug | 17.11.5 |
Python wheel creation
To build the Python wheel Clang is required, the wheel can then be built using:
pip install build
python -m build --wheel
The wheel should now be in the dist directory.
Versioning
This project uses Calendar Versioning (CalVer) in the format: YYYY.0M.Micro[.Modifier]
- YYYY – 4-digit release year (e.g., 2025)
- 0M – 2-digit Zero-padded release month (e.g., 07 for July)
- Micro – The third and usually final number in the version. Sometimes referred to as the "patch" segment.
- Modifier - Optional text tag used to signify extra information
about the build. Currently accepted options values:
- .dev0 - (default) Any build produced with default configuration will have this tag.
- no tag (empty string) - builds produced for release will have no tag at all.
License
TOSA Converter for TFLite is distributed under the Apache 2.0 License.
Note: the code under tosa_converter_for_tflite/tfl_passes was migrated over from the TensorFlow project and therefore inherits copyright attributed to The TensorFlow Authors and Google Inc. This code is also distributed under the Apache 2.0 License.
Trademarks and Copyrights
- Bazel(tm) is a trademark of Google(r) LLC.
- Git(tm) is a trademark of Software Freedom Conservancy.
- LLVM(r) and the LLVM logo are trademarks of the LLVM Foundation.
- Linux(r) is the registered trademark of Linus Torvalds in the U.S. and elsewhere.
- Python(r) is a registered trademark of the Python Software Foundation.
- TensorFlow(tm), the TensorFlow logo and any related marks are trademarks of Google Inc.
- Ubuntu(r) is a registered trademark of Canonical(r) Ltd.
- Visual Studio(r) is a registered trademark of Microsoft(r) Corporation.
- Windows(r) is a registered trademark of Microsoft(r) Corporation.
- CUDA(tm) is a registered trademark of NVIDIA(r) Corporation
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tosa_converter_for_tflite-2026.2.0-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: tosa_converter_for_tflite-2026.2.0-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 9.2 MB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6d2d76744e4bed6845ff7ed61636ff0839d89a9ad547532140c3a047f5adb8d
|
|
| MD5 |
dcba16cfeda5a22b0dc3aaf124e40f3f
|
|
| BLAKE2b-256 |
c248acad200d735745f5527f6e7d8f726529a240b21d145ccf1e0e70e9b5041e
|
File details
Details for the file tosa_converter_for_tflite-2026.2.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: tosa_converter_for_tflite-2026.2.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 25.5 MB
- Tags: CPython 3.13, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dc3b52a9aefdf359aef631eed20669e178c0c89a706df5fa675ba5252ecd0591
|
|
| MD5 |
dbb915ff8942551d4d2ba6b809459e92
|
|
| BLAKE2b-256 |
1f0e2d0d632cff8ac155d43a1a8a5e8011bd03d65dd994638aed6b8319b62af8
|
File details
Details for the file tosa_converter_for_tflite-2026.2.0-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.
File metadata
- Download URL: tosa_converter_for_tflite-2026.2.0-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 26.6 MB
- Tags: CPython 3.13, manylinux: glibc 2.27+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
241fb6950ef5fea36e5cbb0da8f0eefdb3209a857c9b59d9344b427c7609e730
|
|
| MD5 |
471ac0e556c15c0407e10eed2b497e93
|
|
| BLAKE2b-256 |
83fe47a342c1657e453918c119aa31b321373ce12d3ae2a2101ca07554056523
|
File details
Details for the file tosa_converter_for_tflite-2026.2.0-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: tosa_converter_for_tflite-2026.2.0-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 9.2 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
019b3213394c4c59a21463e69bd2f7183f7e65e424ec489683ba0fa071172af1
|
|
| MD5 |
951bf42406837bbe7ced7677932d7888
|
|
| BLAKE2b-256 |
22e0c0872bfd1881c17d3967e25b25be1e7370e6080d682a93ee8dceb82b0dbe
|
File details
Details for the file tosa_converter_for_tflite-2026.2.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: tosa_converter_for_tflite-2026.2.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 25.5 MB
- Tags: CPython 3.12, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
135303f11cd8995b20f29a7cb390a9acb6d393390769cb5e3a8bc2198ab31fde
|
|
| MD5 |
2132beb13f718b9ae44377c5447a7755
|
|
| BLAKE2b-256 |
8328e2969ab1fb65bb706abe040eea75563fddfa3cba6fcfe02af1c57b40472c
|
File details
Details for the file tosa_converter_for_tflite-2026.2.0-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.
File metadata
- Download URL: tosa_converter_for_tflite-2026.2.0-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 26.6 MB
- Tags: CPython 3.12, manylinux: glibc 2.27+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0995dc905dd9e546aa5a64dd264b68f29542ce57391ceabde1e36f7acf5376f2
|
|
| MD5 |
ddc5af014c0f74eae30af9941fcd5322
|
|
| BLAKE2b-256 |
279f5bb9c3c4d4b2d6ad0506786d18cd52c0b047f694e91d501b0519f009ae98
|
File details
Details for the file tosa_converter_for_tflite-2026.2.0-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: tosa_converter_for_tflite-2026.2.0-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 9.2 MB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dcf58f30ce6f467fbe5fa9dbf2ac914b857cdf25774e707d68d1f681cccce457
|
|
| MD5 |
5d543e90f666530537a6149a7d642cab
|
|
| BLAKE2b-256 |
87022fa7b835c516756fdf2abf19e02ccd688be7ed89180a02c4e917dd1cc4d0
|
File details
Details for the file tosa_converter_for_tflite-2026.2.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: tosa_converter_for_tflite-2026.2.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 25.5 MB
- Tags: CPython 3.11, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
149c24df7bc89e0ada928107114d83228efe0f075156078492a598e5c9483150
|
|
| MD5 |
553f0d407f181b8c874c1421d93a5848
|
|
| BLAKE2b-256 |
5589d6eec09b6f77819344df909eed0de72c7a28b176554754f03b8f73298faa
|
File details
Details for the file tosa_converter_for_tflite-2026.2.0-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.
File metadata
- Download URL: tosa_converter_for_tflite-2026.2.0-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 26.6 MB
- Tags: CPython 3.11, manylinux: glibc 2.27+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
30ef9439cf391bda1fb25d950044497ae3616e9733e071683e7b2619c9c249f2
|
|
| MD5 |
a708130964ebfe8997432331fc08cbc7
|
|
| BLAKE2b-256 |
e4d92169cefa1240817b4f67ea2a0393961add0ad94c5768a8e3041a829828b6
|
File details
Details for the file tosa_converter_for_tflite-2026.2.0-cp310-cp310-win_amd64.whl.
File metadata
- Download URL: tosa_converter_for_tflite-2026.2.0-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 9.2 MB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
225a7b9827adb69e6eea1378d4b2db661f423b07c5be5de4789e79a1d342d500
|
|
| MD5 |
7172c6a28c0e6587e7f168a7db28456a
|
|
| BLAKE2b-256 |
67630df711a0fd03b1b3fb76ff2cd71519faba9ae91aeb9d63574cc6141d166e
|
File details
Details for the file tosa_converter_for_tflite-2026.2.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: tosa_converter_for_tflite-2026.2.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 25.5 MB
- Tags: CPython 3.10, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a2cd86305d96904fd95dd1e50b59efeb6969c1349db4adac0a569c7e274c2f3f
|
|
| MD5 |
d0725acad0698deafaa7c967cb21ac2c
|
|
| BLAKE2b-256 |
a7d21243fc77c7f1e2cea22a0df13b95a46355358ff4eb33e20a060f6e5e72b9
|
File details
Details for the file tosa_converter_for_tflite-2026.2.0-cp310-cp310-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.
File metadata
- Download URL: tosa_converter_for_tflite-2026.2.0-cp310-cp310-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 26.6 MB
- Tags: CPython 3.10, manylinux: glibc 2.27+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a9d5d25d811f93ae80ca1bbcdb1935d8bd77fcdd7f1febce87161c706e7ff363
|
|
| MD5 |
6658f9840d03df742abdd2ffb750a5db
|
|
| BLAKE2b-256 |
4272ef28d5ba17acceaf10695809597ace9ab358733b8a8f1f08251f5f0aa387
|