Views
No views yet
CompiledModel GPU
delegate (no CPU fallback). DehazeFormer (TIP 2023,
MCT curve-mapping variant, trained by the author on a mixed dataset for real-world haze)
removes fog / haze / smoke and restores contrast and color.
grid_sample mapping), so output resolution is independent of the network.[1, 3, 256, 256] NCHW, RGB in [-1, 1] (x/255*2-1).[1, 72, 256, 256] curve parameters — layout [3 out-channels × 3 in-channels × 8 levels].out[c] = Σᵢ trilinear(curve[c][i], depth = xᵢ, y, x) with
align_corners=true and border clamping, then clamp(-1,1)*0.5+0.5.reflection_pad2d to GATHER_ND, rejected
by the delegate), Swin window partition/reverse in ≤4D + baked relative-position bias,
SKFusion 5D→4D pairwise softmax, Conv+PixelShuffle → zero-stuff ConvTranspose, and — the new
finding — hierarchical means for the RLN global norm (a single MEAN over 1.5M elements
overflows the Mali fp16 accumulator → NaN; equal-window avg_pool stages are mathematically
identical and fp16-safe). Desktop corr vs PyTorch is 1.0000000.1val options = CompiledModel.Options(Accelerator.GPU)
2val model = CompiledModel.create(context.assets, "dehazeformer_base.tflite", options, null)
3val inBufs = model.createInputBuffers()
4val outBufs = model.createOutputBuffers()
5
6inBufs[0].writeFloat(inputNCHW) // [1,3,256,256] RGB in [-1,1]
7model.run(inBufs, outBufs)
8val curves = outBufs[0].readFloat() // [72*256*256] curve params
9// apply curves to the full-res frame host-side (see the sample's Dehazer.applyCurves)1import numpy as np
2from ai_edge_litert.compiled_model import CompiledModel
3
4model = CompiledModel.from_file("dehazeformer_base.tflite")
5inputs = model.create_input_buffers(0)
6outputs = model.create_output_buffers(0)
7inputs[0].write(np.ascontiguousarray(x, np.float32)) # [1,3,256,256] RGB in [-1,1]
8model.run_by_index(0, inputs, outputs)
9n = model.get_output_buffer_requirements(0, 0)["buffer_size"] // 4
10curves = outputs[0].read(n, np.float32).reshape(72, 256, 256)build_dehaze.py): fetches the author's model code and MIT
checkpoint from the Hugging Face Space and exports the curve-parameter basenet.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 | 2042 / 2042 | ~255 ms |
TFLite benchmark_model (TfLiteGpuDelegateV2) | GPU (OpenCL) | 2042 / 2042 | 375.8 ms |
TFLite benchmark_model | CPU (XNNPACK, 4 threads) | — | 944.3 ms |
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.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 |
|---|---|---|---|---|
dehazeformer_base.tflite | 2,183.8 ms | 2,176.8–2,232.3 ms | 150 | 252 MB |