Newer
Older
<!--
SPDX-FileCopyrightText: Copyright 2025 Arm Limited and/or its affiliates <open-source-office@arm.com>
SPDX-License-Identifier: Apache-2.0
-->
# TOSA converter for TFLite
A tool to legalize TFLite FlatBuffer to TOSA MLIR Bytecode.
## Python wheel creation
To build the Python wheel Clang is required, the wheel can then be built using:
```console
pip install build
python -m build --wheel
```
The wheel should now be in the `dist` directory.
## Usage
```python
from tosa_converter_for_tflite import tflite_flatbuffer_to_tosa_mlir_bytecode
tflite_flatbuffer_to_tosa_mlir_bytecode("model_input.tflite", "model_output.tosa.mlirbc")
```
## Command-line Interface (CLI)
The `tosa-converter-for-tflite` CLI provides a simple way to convert `.tflite` models
into TOSA MLIR bytecode. 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:**
```bash
tosa-converter-for-tflite model.tflite -o out.tosa.mlirbc
```
**Read the model from `stdin` and write to a file:**
```bash
cat model.tflite | tosa-converter-for-tflite -o out.tosa.mlirbc
```
**Read from a file and write to `stdout`:**
```bash
tosa-converter-for-tflite model.tflite > out.tosa.mlirbc
```
**Fully stream the model through the CLI and into another tool:**
```bash
cat model.tflite | tosa-converter-for-tflite | <downstream-tool>
```
## Supported Platforms
This tool supports Linux and Windows(r) on x86_64 architectures.
## Versioning
This project uses Calendar Versioning ([CalVer](https://calver.org/)) in the format: `YYYY.0M.Micro`
- **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.
# License
TOSA Converter for TFLite is distributed under the Apache 2.0 License.
LLVM and the LLVM logo are trademarks of the LLVM Foundation.
TensorFlow, the TensorFlow logo and any related marks are trademarks of Google Inc.