|
||
---|---|---|
.. | ||
common | ||
experimental | ||
ir | ||
python | ||
quantization | ||
sparsity | ||
tests | ||
transforms | ||
utils | ||
BUILD | ||
converter_gen.cc | ||
emit_error_reporter.cc | ||
emit_error_reporter.h | ||
flatbuffer_export_flags.h | ||
flatbuffer_export.cc | ||
flatbuffer_export.h | ||
flatbuffer_import.cc | ||
flatbuffer_import.h | ||
flatbuffer_operator.cc | ||
flatbuffer_operator.h | ||
flatbuffer_to_string.cc | ||
flatbuffer_translate_flags.h | ||
flatbuffer_translate.cc | ||
flatbuffer_translate.h | ||
json_to_flatbuffer.cc | ||
mlir_tflite_runner.cc | ||
README.md | ||
tf_tfl_passes.cc | ||
tf_tfl_passes.h | ||
tf_tfl_translate_cl.cc | ||
tf_tfl_translate_cl.h | ||
tf_tfl_translate.cc | ||
tf_to_tfl_flatbuffer.cc | ||
tf_to_tfl_flatbuffer.h |
The new MLIR based
TensorFlow to TensorFlow Lite converter
This directory contains:
- MLIR dialects, transformation passes and utilities for TensorFlow Lite.
API:
The API for converting TensorFlow models to TensorFlow Lite will be through
tf.lite.TFLiteConverter
. All the conversion code is open sourced, and
the API will be integrated soon.
The conversion process from TensorFlow to TensorFlow Lite includes the
following major passes:
- Import from GraphDef, in .pb or .pbtxt format, into MLIR.
- Raise to Control-flow-graph. Converts TF Control Flow dialect to TF dialect.
- The Canonicalization pass iteratively applies canonicalization transformations in a greedy way until no further changes occur. Canonicalization includes constant folding.
- The Legalize pass converts TensorFlow operations to TensorFlow Lite ones. The operations that cannot be mapped to TensorFlow Lite dialect are left as TensorFlow operations. Unsupported op handling follows the proposed TFLite mechanism.
- Optimizations are performed in both the TF & TFLite dialect; aiming for small size and high performance (among the core value proposition of TensorFlow Lite models).
- The Export pass writes out TensorFlow Lite FlatBuffer format. This pass operates on MLIR TensorFlow Lite dialect and is simple/direct translation.
See https://github.com/tensorflow/tensorflow/blob/master/tensorflow/compiler/mlir/lite/tf_tfl_passes.cc for the full list of MLIR passes for conversion from TensorFlow to TensorFlow Lite.