Sort tensor list by name for serialization

- Tensors are stored in an unordered_map from mlir::Value::hash_value
  to tensor name.
- Before serialization, sort the tensor list alphabetically by name
  so that tensors always appear in a determinstic (and logical) order.

Signed-off-by: Jared Smolens <jared.smolens@arm.com>
Change-Id: I21c0e2ec04b7520e6a753b8bf62572a702002d5b
1 file changed
tree: 06e8dba86ad2365a15e0a6f600c4dc1c1088d1ed
  1. .clang-format
  2. .gitmodules
  3. CMakeLists.txt
  4. LICENSE.txt
  5. README.md
  6. include/
  7. src/
  8. third_party/
README.md

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 https://review.mlplatform.org/plugins/gitiles/tosa/serialization_lib The library includes a FlatBuffers schema and a C++ API for reading and writing a TOSA graph as a flatbuffer.

Compiling

This repository does not currently build standalone. It must be included 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.

Usage

To serialize a TOSA MLIR graph to TOSA flatbuffer binary file:

<YOUR_MLIR_OPTIMIZER> --tosa-serialize <TOSA_MLIR_GRAPH>
--tosa-flatbuffer-filename <TOSA_FLATBUFFER_FILENAME>

To serialize a TOSA MLIR graph to TOSA flatbuffer JSON file:

<YOUR_MLIR_OPTIMIZER> --tosa-serialize <TOSA_MLIR_GRAPH>
--tosa-flatbuffer-schema <PATH_TO_TOSA_FLATBUFFER_SCHEMA>
--tosa-flatbuffer-filename <TOSA_FLATBUFFER_FILENAME>

where <PATH_TO_TOSA_FLATBUFFER_SCHEMA> is provided within the serialization library submodule in third_party/serialization_lib/schema/tosa.fbs

License

The TOSA MLIR Translator is licensed under Apache-2.0 with LLVM Exceptions.