.tflite is a binary file format for TensorFlow Lite models, based on Google's FlatBuffers technology. The format is optimized for efficient inference on mobile, embedded and edge devices with limited resources. Unlike other serialization formats, FlatBuffers provides direct data access without parsing and copying, which is critical for fast model startup. According to the TensorFlow Lite Converter Guide, 2025, the .tflite file contains a computation graph, quantized or full-precision weights, and metadata for the interpreter. .tflite is the standard format for on-device ML in the Google ecosystem.
Key Takeaways
.tflite is a serialized representation of a machine learning model optimized for inference on devices with limited memory and computing power. Unlike the SavedModel format, which stores a graph in protobuf and requires significant resources to load, .tflite uses FlatBuffers — a serialization library with copy-free data access.
The .tflite format is designed with mobile platform specifics in mind: minimal memory consumption during loading, fast startup, and support for quantized weights. A .tflite file does not support training — only inference. This is a fundamental difference from full TensorFlow formats, allowing a significant reduction in runtime size.
According to Google Research, 2024, models in .tflite format with INT8 quantization load 60% faster than similar FP32 models and consume 40% less RAM during inference.
A .tflite file consists of several sections organized according to the FlatBuffers schema. The main section is Model, which contains the computation graph (SubGraph), a list of operators (OperatorCodes) and weight buffers. Each SubGraph contains tensors, operators, input and output indices.
The OperatorCodes section contains identifiers of all operators used in the model — Conv2D, DepthwiseConv2D, FullyConnected, Softmax and others. Each operator has a code from the predefined BuiltinOperator list. If the model contains operations not in the list, they are marked as Custom and require implementation via a delegate or custom operator.
The Buffers section contains binary weight data of the model. Depending on the quantization mode, weights can be stored in FP32, FP16, INT8 or in a quantized format with scaling parameters. Buffers are mapped directly into memory via mmap, eliminating additional copying.
| Section | Purpose |
|---|---|
| Model | Root structure, version, description |
| SubGraph | Computation graph: tensors, operators, inputs/outputs |
| OperatorCodes | List of used operators |
| Buffers | Binary weight data of the model |
| Metadata | Metadata: version, author, description |
| SignatureDef | Named inputs and outputs for API |
.tflite supports three quantization modes. Full integer INT8 quantization — weights and activations are represented as 8-bit integers. Conversion requires a representative dataset for calibrating activation ranges. Model size is reduced by 4x.
FP16 quantization — weights are converted to 16-bit floating point numbers. This mode requires no calibration and provides minimal accuracy loss. Activations remain in FP32. Model size is reduced by 2x. Recommended for devices with FP16 support on GPU and NPU.
Dynamic quantization — weights are converted to INT8 but activations are computed in FP32. Model size is reduced by 4x while accuracy remains higher than full INT8. According to Google ML Performance Benchmarks, this mode is optimal for NLP models and models with high accuracy sensitivity.
To convert a model to .tflite, use TFLite Converter — a TensorFlow component available via the Python API tf.lite.TFLiteConverter. The converter supports three sources: SavedModel, Keras H5 and ConcreteFunction. A minimal Keras model conversion example:
import tensorflow as tf
# Load the trained Keras model from file
model = tf.keras.models.load_model("my_model.h5")
# Convert to .tflite with dynamic quantization
converter = tf.lite.TFLiteConverter.from_keras_model(model)
converter.optimizations = [tf.lite.Optimize.DEFAULT]
tflite_model = converter.convert()
# Write the converted model to a .tflite file
with open("model.tflite", "wb") as f:
f.write(tflite_model)
For conversion with full INT8 quantization, a calibration dataset is required. Provide a representative_dataset to determine activation ranges:
converter = tf.lite.TFLiteConverter.from_saved_model("saved_model")
converter.optimizations = [tf.lite.Optimize.DEFAULT]
converter.representative_dataset = representative_dataset
converter.target_spec.supported_ops = [
tf.lite.OpsSet.TFLITE_BUILTINS_INT8
]
converter.inference_input_type = tf.uint8
converter.inference_output_type = tf.uint8
tflite_quant_model = converter.convert()
Google provides a set of tools for analyzing and optimizing .tflite models. TFLite Benchmark Tool measures inference time on device and outputs statistics for each operator. TFLite Model Inspector visualizes the computation graph and shows tensor sizes.
Netron — a cross-platform model visualizer supporting .tflite alongside ONNX, Core ML and PyTorch. Netron displays the graph structure, parameters of each operator and connections between tensors. Useful for debugging during conversion.
The TFLite Metadata API allows adding metadata to .tflite files: model description, input data format, measurement units, author information. Metadata is used by the Task Library for automatic preprocessing and postprocessing configuration.
Example of loading a .tflite model on iOS with Swift API. TFLite Swift API provides an Interpreter for loading a model from the bundle and running inference. Specify a delegate for hardware acceleration via Core ML Delegate:
import TensorFlowLite
guard let modelPath = Bundle.main.path(
forResource: "model", ofType: "tflite"
) else { return }
let interpreter = try Interpreter.init(modelPath: modelPath)
try interpreter.allocateTensors()
// Prepare input data for the model
let inputData = Data.init(count: 1 * 224 * 224 * 3)
try interpreter.copy(inputData, toInputAt: 0)
// Run model inference
try interpreter.invoke()
// Read output tensor data
let outputTensor = try interpreter.output(at: 0)
let results = outputTensor.data.withUnsafeBytes {
Array($0.bindMemory(to: Float32.self))
}
Frequently Asked Questions
The .tflite file has a binary FlatBuffers format and cannot be read in a text editor. Use Netron or TFLite Model Inspector to view and visualize the model structure.
Use tf.lite.experimental.Analyzer.analyze(model_path) in Python or TFLite Benchmark Tool with the --print_model_details flag. These tools output a complete list of operators with parameters.
.tflite is optimized for inference on mobile devices and uses FlatBuffers. ONNX is a universal format for exchanging models between frameworks with protobuf serialization. TFLite has built-in quantization support.
No, reverse conversion does not exist due to information loss during quantization and optimization. The original TensorFlow model should be saved separately for further training or modifications.
Use the TFLite Metadata Writer API in Python. The API allows adding a description, input/output format, measurement units and example data for the Task Library.
Summary
We will develop a mobile application turnkey
IT Sectr creates iOS and Android applications for startups and businesses since 2017. We will advise you and propose the best solution.
Read also