A shelf-detection model had to run on Android phones held up in a store aisle, with no server in the loop. The model was already quantised and small. The remaining question was which part of the phone should run it.
The obvious path
Android ships a neural networks API, NNAPI, built for exactly this job. It hands the model to whatever accelerator the phone has: a neural processor, a DSP or the GPU. On paper it is the right default, because it is the vendor's own route to the vendor's own hardware.
So I started there, and measured it before shipping.
What I measured
Two builds of the same model, on the same phones, with the same input frames:
- NNAPI, letting the system pick the accelerator.
- The plain GPU delegate, which runs the model on the phone's GPU directly.
I timed every frame after a warm-up, because the first few frames include setup cost and make every path look slower than it is.
The GPU delegate was faster on every phone. NNAPI was between one and a half and two and a half times slower, and its timings also varied far more from frame to frame. For a scan that has to keep up with someone walking down an aisle, the variance mattered almost as much as the average.
Why the vendor path lost
NNAPI only helps when the accelerator underneath supports every operation in the model. When it doesn't, parts of the model fall back to slower paths, and data has to move between processors in the middle of a frame. Those handoffs cost more than the accelerator saves.
Which operations are supported changes from one chip to the next. A path that is fast on one phone can be slow on another, and you cannot tell which from the documentation.
What shipped
The GPU delegate shipped on Android. NNAPI was dropped, and I didn't spend time tuning it further, because the GPU path was already fast and predictable across devices.
The general lesson
Measure before optimising. The obvious accelerator is often the slow one, and the only way to know is to time it on the hardware your users carry, after warm-up, across more than one device.