Format:TensorFlow Lite model
| Developer | |
|---|---|
| Magic | TFL3 at offset 4 |
| Extensions | .tflite |
| License | Apache-2.0 |
| On this wiki | Facts · Code · Notes · Topics |
TFLite model file (.tflite): a FlatBuffer with file identifier 'TFL3' at offset 4 and root table Model (schema version 3), run by libtensorflowlite / LiteRT.
Layout
The schema (schema.fbs, now maintained in the LiteRT repository google-ai-edge/LiteRT under tflite/converter/schema) declares file_identifier "TFL3", file_extension "tflite" and root_type Model. In a FlatBuffer the file starts with a uint32 offset to the root table; the 4-byte identifier follows at offset 4, so the first 8 bytes look like 1C 00 00 00 54 46 4C 33 (the offset value varies; Unverified).
Table Model (from the schema): version:uint, operator_codes:[OperatorCode], subgraphs:[SubGraph] (0 is the main model), plus description, buffers, metadata and signature defs. Tensor weights are in the buffers vector. TFLITE_SCHEMA_VERSION is 3 (tensorflow/lite/version.h): the version field of every current file is 3. TensorType enum starts FLOAT32 0, FLOAT16 1, INT32 2, UINT8 3, INT64 4, STRING 5.
Runtime
The C++ runtime builds as libtensorflowlite (tensorflowlite.dll, libtensorflowlite.so; Android apps use libtensorflowlite_jni.so, Unverified) and reports TFLITE_VERSION_STRING (2.19.0 in the pinned source). Since the schema is a FlatBuffer with named fields, a model can be dumped with flatc using schema.fbs or the generated schema_generated.h of the same version.
Note
In the TensorFlow repository tensorflow/lite/schema/schema_generated.h is a stub in the pinned commit; get schema.fbs from LiteRT.
See Technique:Identifying machine-learning models in applications. Related: Format:ONNX model.
Operators and buffers
From schema.fbs (LiteRT 0d58dc4): Model.operator_codes is a vector of OperatorCode tables (deprecated_builtin_code:byte, custom_code:string, version:int = 1, builtin_code:BuiltinOperator); each Operator in a SubGraph refers to its code by index, so the set of operations a model uses is read from that vector. deprecated_builtin_code is one byte for old readers; values from PLACEHOLDER_FOR_GREATER_OP_CODES (127) up live only in builtin_code, so read builtin_code first. The BuiltinOperator enum (int32) starts ADD 0, AVERAGE_POOL_2D 1, CONCATENATION 2, CONV_2D 3, DEPTHWISE_CONV_2D 4, ... CUSTOM 32 (then custom_code names the op, options are FlexBuffers), DELEGATE 51, GELU 150, STABLEHLO_COMPOSITE 206 (no runtime support). The schema comments state that buffer 0 must be an empty sentinel buffer and that Tensor.buffer indexes Model.buffers (0 = no data, such as intermediate results). A Buffer has data:[ubyte] (force_align 16) and, for models over 2 GB, offset and size (ulong) pointing at data stored outside the FlatBuffer relative to the file start. Tensor has shape, type (TensorType: FLOAT32 0, FLOAT16 1, INT32 2, UINT8 3, INT64 4, STRING 5, BOOL 6, INT16 7, COMPLEX64 8, INT8 9, FLOAT64 10, ... INT4 17, BFLOAT16 18), buffer, name and quantization. Schema versions in the header comment: 0 initial, 1 subgraphs, 2 NNAPI-conforming names, 3 buffers moved out of tensors, with 3a to 3d as backward-compatible extensions; the file's Model.version stays 3.
See also
- Format:FlatBuffers (binary layout, vtables, reading without schema)
Code & repositories
- https://github.com/google-ai-edge/LiteRT @
0d58dc4d0838d13ea1e54117f8d386a3bb9b8aa0· license: Apache-2.0 (read from LICENSE; GitHub's API was busy)
LiteRT (TFLite): tflite schema.fbs
Tested on: source read, not run: read source · checked 2026-10-18