TOSA MLIR Translator ========================== # Introduction The *TOSA MLIR Translator* repository implements translators between the TOSA MLIR dialect and serialized representations. The current implementation supports serialization from MLIR form to flatbuffers. A deserializer from flatbuffers to MLIR form is in development. # Dependencies ## TOSA serialization library The library includes a FlatBuffers schema and a C++ API for reading and writing a TOSA graph as a flatbuffer. Check out the required git submodules with: ``` bash git submodule update --init --recursive ``` # Compiling There are two ways of using the TOSA MLIR Translator. ## As part of another MLIR repository The first method involves including this repository within another MLIR repository with a pass manager registering the passes implemented within this repository. The included CMake rules can be used to add this repository as a submodule. The `include/SerializationPasses.h` enables MLIR pass registration inclusion. If target "tosa_serialize" is linked correctly, you should able to see "--tosa-serialize" and "--tosa-serialize-json" options available in your MLIR pass manager/MLIR optimizer. ## As a standalone TOSA Optimizer Driver (`tosa-opt`): See the README.md in the `tosa-opt` directory. # Usage To serialize a TOSA MLIR graph to TOSA flatbuffer binary file: \ --tosa-serialize \ \ --tosa-flatbuffer-filename \ To serialize a TOSA MLIR graph to TOSA flatbuffer JSON file: \ --tosa-serialize-json \ \ --tosa-flatbuffer-schema \ \ --tosa-flatbuffer-filename \ where \ is provided within the serialization library submodule in third_party/serialization_lib/schema/tosa.fbs # Pre Commit Checks Before pushing a commit, pre commit checks must be run to ensure conformity. ## Prerequisites * clang-format (tested with 14) * pre-commit (tested with 3.8.0) Install pre-commit with: ``` bash pip install pre-commit==3.8.0 ``` ## Run Pre Commit Checks ``` bash pre-commit run --all ``` # 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 The *TOSA MLIR Translator* is licensed under Apache-2.0 with LLVM Exceptions.