LiteRT is Google's on-device runtime, the new name for TensorFlow Lite (Android: com.google.ai.edge.litert:litert), and litert-torch, the renamed ai-edge-torch, is its PyTorch converter: a PyTorch model converted unmodified with litert_torch.convert matched the original to 4e-7 on a Galaxy S26 (measured, LiteRT 2.2.0, Android 16, 2026-09-05).
On-device real-time semantic segmentation running fully on the LiteRT
CompiledModel GPU delegate (no CPU fallback). PIDNet-S
(CVPR 2023) segments a road scene into the 19 Cityscapes classes at ~17 FPS on a
Pixel 8a.
PIDNet is a pure CNN — no attention, no dynamic shapes at a fixed input size, and
align_corners=False on every bilinear resize. It converts to a fully
GPU-compatible graph with zero patches: CONV_2D ×75, RESIZE_BILINEAR ×11
(align_corners=False), AVERAGE_POOL_2D, ADD/MUL/SUB/SUM, LOGISTIC —
0 tensors of rank > 4, 0 GPU-incompatible ops. The converted graph matches the
original PyTorch model bit-for-bit on CPU (corr 0.99999999999, 100% argmax); on the
Mali GPU (fp16) it agrees with the fp32 reference at 97% of pixels with correct
classes.
Minimal usage
Kotlin (Android, LiteRT CompiledModel GPU)
kotlin
1val options = CompiledModel.Options(Accelerator.GPU)2val model = CompiledModel.create(context.assets,"pidnet_s.tflite", options,null)3val inBufs = model.createInputBuffers()4val outBufs = model.createOutputBuffers()56inBufs[0].writeFloat(inputNCHW)// [1,3,1024,1024], RGB, ImageNet-norm7model.run(inBufs, outBufs)8val logits = outBufs[0].readFloat()// [19,128,128] (NCHW, batch dropped)910// argmax over 19 classes per pixel:11val hw =128*12812val label =IntArray(hw){ i ->13var best =0;var bv = logits[i]14for(c in1 until 19){val v = logits[c * hw + i];if(v > bv){ bv = v; best = c }}15 best
16}
Python (LiteRT / ai-edge-litert)
python
1from ai_edge_litert.interpreter import Interpreter
2import numpy as np
34it = Interpreter(model_path="pidnet_s.tflite"); it.allocate_tensors()5inp, out = it.get_input_details(), it.get_output_details()6it.set_tensor(inp[0]["index"], x)# [1,3,1024,1024] float32, ImageNet-norm7it.invoke()8logits = it.get_tensor(out[0]["index"])[0]# [19,128,128]9label = logits.argmax(0)# [128,128] class ids
Conversion
Re-authored/converted with litert-torch (build_pidnet.py): the trained PIDNet-S
weights are loaded from an ONNX mirror whose initializer names match the original
repo's PyTorch keys, then converted directly — zero GPU patches.
Performance
Measured on a Pixel 8a (Tensor G3, Android 16) with the standard TFLite benchmark_model tool — 10 warm-up runs then 50 timed runs, reported as the tool's mean.
Runtime
Backend
Graph on GPU
Latency
TFLite benchmark_model (TfLiteGpuDelegateV2)
GPU (OpenCL)
190 / 190
61.5 ms
TFLite benchmark_model
CPU (XNNPACK, 4 threads)
—
719.2 ms
Any on-device figure recorded when this model shipped came from a different runtime. It was taken through LiteRT's own CompiledModel accelerator (logcat reports it as LITERT_CL), which is the path the Kotlin sample app and the LiteRT API use, and it appears elsewhere on this card. The rows above are the classic TFLite OpenCL delegate, measured with a tool anyone can download and re-run. The two are not comparable, so read the rows above as a reproducible floor rather than as this model's speed on LiteRT.
Snapdragon NPU (Hexagon)
The NPU is 2.95x faster than the GPU (5.48 ms against 16.20 ms) and loads 12.62x faster (119 ms against 1502 ms).
backend
inference (median / min)
load
NPU (Hexagon v81)
5.48 ms / 5.44 ms
119 ms
GPU (Adreno)
16.20 ms / 15.73 ms
1502 ms
Measured on a Samsung Galaxy S26 (Snapdragon 8 Elite Gen 5 / SM8850, Hexagon v81, Android 16), LiteRT CompiledModel 2.2.0, one accelerator per process, 5 warm-up runs then N=50 timed runs, median reported. Every run held thermal status NONE throughout. Headroom 0.67, where 1.0 is the throttling threshold.
The NPU rows here ran artifacts compiled ahead of time for SM8850 with QAIRT 2.47.0; the GPU rows ran the published files as they are. LiteRT can also compile for the NPU on the device at first load, which is what lets you ship the published file unchanged — that path and the ten runtime libraries it needs are in the NPU recipe, and we did not measure it here. GPU wiring is in the GPU recipe.
Raspberry Pi 5 (CPU)
Measured on a Raspberry Pi 5 Model B Rev 1.1 (8 GB, Raspberry Pi OS 64-bit) with the LiteRT benchmark_model tool from litert-cli-nightly 0.2.0.dev20260805: CPU inference (XNNPACK, 4 threads), 3 invocations per file of 10 warm-up plus 50 timed runs (the tool caps a phase at 150 s, so very slow graphs run fewer — the Runs column is the actual timed total). The latency is the median across invocations; the spread is the min–max over all timed runs. No thermal throttling occurred during these runs (vcgencmd get_throttled stayed 0x0).
File
Inference (median)
Spread (min–max)
Runs
Peak memory
pidnet_s.tflite
482.3 ms
480.3–485.6 ms
150
201 MB
License
MIT (PIDNet / XuJiacong/PIDNet). Cityscapes label taxonomy from the Cityscapes dataset.