Measured on device (edge-compat): Galaxy S26 Β· LiteRT 2.2.0 Β· GPU (ML Drift) Β· 3.66 ms p50 (2026-08-25); Galaxy S26 Β· LiteRT 2.2.0 Β· NPU (QNN/HTP) Β· 21.1 ms p50 (2026-08-25); Raspberry Pi 5 Β· LiteRT 2.2.0.dev20260804 Β· CPU/XNNPACK, 4 threads Β· 102 ms p50 (2026-08-31); browser Β· Chromium 151 on M4 Max Β· LiteRT.js 2.5.3 Β· WebGPU Β· 3.40 ms p50 Β· output matches CPU (2026-08-11). Record: https://github.com/john-rocky/edge-compat/blob/main/cards/unisal-saliency/CARD.md
UniSal β LiteRT (on-device visual saliency prediction, fully-GPU)
UniSal (rdroste), visual saliency prediction β a heatmap of where humans
look in an image β converted to LiteRT and running fully on the CompiledModel GPU (ML Drift) on
Android. MobileNetV2 encoder + bilinear decoder, 3.71 M params / 6.5 MB fp16.
On-device (Pixel 8a, Tensor G3 β verified)
| nodes on GPU | 158 / 158 LITERT_CL (full residency) |
| inference | ~3 ms (256Γ256) |
| size | 6.5 MB (fp16) |
| accuracy | device-vs-PyTorch corr 0.9998 |
image[1,3,256,256] (ImageNet mean/std) β[GPU: UniSal]β saliency[1,1,256,256] (higher = more attended)
Minimal usage
Android (Kotlin, CompiledModel GPU)
val model = CompiledModel.create(context.assets, "unisal_fp16.tflite",
CompiledModel.Options(Accelerator.GPU), null)
val inputs = model.createInputBuffers()
val outputs = model.createOutputBuffers()
inputs[0].writeFloat(chw) // [1,3,256,256] ImageNet-normalized, NCHW
model.run(inputs, outputs)
val sal = outputs[0].readFloat() // [1,1,256,256] saliency (higher = more attended)
Python (desktop verification)
MEAN = np.array([0.485, 0.456, 0.406], np.float32)
STD = np.array([0.229, 0.224, 0.225], np.float32)
import numpy as np
from PIL import Image
from ai_edge_litert.interpreter import Interpreter
img = Image.open("photo.jpg").convert("RGB").resize((256, 256))
x = ((np.asarray(img, np.float32) / 255 - MEAN) / STD).transpose(2, 0, 1)[None]
it = Interpreter(model_path="unisal_fp16.tflite"); it.allocate_tensors()
it.set_tensor(it.get_input_details()[0]["index"], x); it.invoke()
s = it.get_tensor(it.get_output_details()[0]["index"])[0, 0] # [256,256]
s = (s - s.min()) / (s.max() - s.min())
Image.fromarray((s * 255).astype(np.uint8)).save("saliency.png")
How it converts (litert-torch) β three numerically-exact fixes
- Strided subsample
x[..., ::2, ::2]βF.avg_pool2d(x, 1, 2)(same pixels; avoidsGATHER_ND). - Bake the 16 Gaussian prior maps (size-only constants; avoids
GATHER_ND/BROADCAST_TO). F.pad(replicate)β 0-pad for the 41Γ41 Gaussian smoothing (which is kept β it suppresses border artifacts, not cosmetic).
Result: banned ops NONE, β€4D, tflite-vs-torch corr 1.0, device-vs-torch corr 0.9998. Static-image path (Bypass-RNN + SALICON domain pinned); the spatial log-softmax / normalization runs in the app.
Preprocessing
Center-crop, resize 256Γ256, /255, ImageNet mean/std, NCHW.
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 |
|---|---|---|---|
LiteRT CompiledModel (LITERT_CL) |
GPU | 158 / 158 | ~3 ms |
TFLite benchmark_model (TfLiteGpuDelegateV2) |
GPU (OpenCL) | 158 / 158 | 20.2 ms |
TFLite benchmark_model |
CPU (XNNPACK, 4 threads) | β | XNNPACK declined the graph |
The two GPU rows are different runtimes, not a contradiction. The LITERT_CL figure is the one recorded when this model shipped, taken through LiteRT's own CompiledModel accelerator β the path the Kotlin sample app and the LiteRT API use. The TfLiteGpuDelegateV2 figure is the classic TFLite OpenCL delegate, measured with a tool anyone can download and re-run. They agree on how much of the graph the GPU takes; they disagree on speed, and the classic delegate is the slower of the two here. Read the TfLiteGpuDelegateV2 row as a reproducible floor, not as this model's speed on LiteRT.
XNNPACK declines these fp16 graphs β it reports failed to delegate DEPTHWISE_CONV_2D and then fails to allocate tensors β so there is no usable CPU number. Disabling XNNPACK falls back to reference kernels, which measured about 20Γ slower than the GPU on models of this size and would not represent CPU inference anyone would ship.
Snapdragon NPU (Hexagon)
The GPU is faster: 3.66 ms against 21.12 ms on the NPU, a factor of 5.77. The NPU still loads 21x faster (103 ms against 2136 ms).
| backend | compiled | inference (median / min) | load |
|---|---|---|---|
| NPU (Hexagon v81) | on-device JIT | 21.12 ms / 20.65 ms | 103 ms |
| GPU (Adreno) | β | 3.66 ms / 3.46 ms | 2136 ms |
Measured on a Samsung Galaxy S26 (Snapdragon 8 Elite Gen 5 / SM8850, Hexagon v81, Android 16) with 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.76, where 1.0 is the throttling threshold.
The NPU rows ran the published file unchanged. LiteRT compiled it for the Hexagon on the device at first load. That first compile took 937 ms here. The load column above is the cached load every later run pays. Recipe and the runtime libraries it needs: NPU guide.
GPU wiring: GPU guide.
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 |
|---|---|---|---|---|
unisal_fp16.tflite |
102.0 ms | 101.5β103.3 ms | 150 | 895 MB |
License
Apache-2.0. Upstream: rdroste/unisal.
- Downloads last month
- 85
