C.W.K.
Stream
Lesson 04 of 05 · published

TFLite Interpreter and Hardware Delegates

~11 min · interpreter, delegates, edge-tpu, core-ml

Level 0Level 0
0 XP0/78 lessons0/17 achievements
0/100 XP to next level100 XP to go0% complete

Where the model actually runs

The TFLite Interpreter is the runtime that executes .tflite models on device. On Python (useful for testing on desktop before deploying to mobile), use tf.lite.Interpreter.

Delegates let TFLite offload computation to specialized hardware. Each delegate is a plugin — TFLite tries each supported op on the delegate first, falls back to CPU for unsupported ops.

DelegateHardwarePlatformSupported quant
GPU DelegateOpenCL/Metal GPUAndroid, iOS, Linuxfp32, fp16, dynamic range
Core ML DelegateNeural Engine (A12+)iOS 12+fp32, fp16
Edge TPUCoral Edge TPULinux/Win/macOSfull int8 only
NNAPINeural Proc UnitAndroid 8.1–14varies by device

The delegate choice and quantization choice are coupled. Targeting Coral Edge TPU? You must use full int8 quantization. Targeting iOS Neural Engine? Use fp16. Picking a quantization tier without considering the deployment target wastes work.

Code

Python interpreter — desktop 테스트·python
import tensorflow as tf
import numpy as np

interpreter = tf.lite.Interpreter(model_path='model.tflite')
interpreter.allocate_tensors()

input_details  = interpreter.get_input_details()
output_details = interpreter.get_output_details()

print("Input shape:", input_details[0]['shape'])
print("Input dtype:", input_details[0]['dtype'])

# Run inference
input_data = np.random.rand(1, 224, 224, 3).astype(np.float32)
interpreter.set_tensor(input_details[0]['index'], input_data)
interpreter.invoke()

output = interpreter.get_tensor(output_details[0]['index'])
print("Predictions:", output)
Edge TPU delegate·python
import tflite_runtime.interpreter as tflite

# Coral Edge TPU — requires libedgetpu installed
interpreter = tflite.Interpreter(
    model_path='model_edgetpu.tflite',
    experimental_delegates=[
        tflite.load_delegate('libedgetpu.so.1')      # Linux
        # tflite.load_delegate('libedgetpu.1.dylib')  # macOS
        # tflite.load_delegate('edgetpu.dll')          # Windows
    ]
)
interpreter.allocate_tensors()

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.