Introduction
A .tflite file is a trained model prepared to run on phones, embedded
boards and microcontrollers with TensorFlow Lite, which Google renamed
LiteRT in 2024. The converter takes a
TensorFlow, Keras or JAX model, fixes its graph, and often quantises the weights to
8-bit integers so the file is smaller and runs faster on small chips. The result holds
both the network and its weights in one file that can be mapped into memory and used
without parsing.
Structure
The file is a FlatBuffers buffer whose schema,
schema.fbs, is part of the TensorFlow source. It starts with a 4-byte offset
to the root table, then the file identifier TFL3 at bytes 4 to 7.
0Root offset little-endian, to the Model table4 bytes4IdentifierTFL34 bytes8Tables the Model and everything it refers tothe rest
The Model table has a schema version, a list of operator codes such as
CONV_2D and FULLY_CONNECTED, one or more subgraphs, a list of
buffers and optional metadata. Each subgraph lists its tensors (with type, shape,
quantisation parameters and the buffer that holds their values), its inputs and outputs,
and its operators in the order they run. Large models may keep buffer data after the
FlatBuffer instead of inside it.
Links
Software
- LiteRT (Android, iOS, Linux, microcontrollers)
- TensorFlow, which converts models to TensorFlow Lite
- Netron, a viewer that draws the network (Windows, macOS, Linux, web)
Developers
- LiteRT, runtime with APIs for Java, Kotlin, Swift, C++ and Python
- FlatBuffers, for reading the file with the published schema