GpuCheck

Can this phone's GPU run a model, and run it right? Asked once per model and system build.

The check runs in its own process (GpuCheckService, :gpucheck) because a GPU driver that can't handle the model doesn't throw: LiteRT aborts the whole process (seen on the edge 50 with an earlier export). So the check writes "running" first; if its process dies, that's all the app ever finds, and it uses the CPU. A GPU that does compile must also give the CPU's answer on a fixed test image (fp16 on this model compiled fine and returned wrong vectors).

Types

Link copied to clipboard
class Target(val id: String, val file: File, val inputs: Int)

A LiteRT model to check: id names its result file; inputs floats of test input.

Functions

Link copied to clipboard
suspend fun useGpu(context: Context, model: AiModel): Boolean

True when model should run on the GPU. Checks on first call (up to two minutes).

suspend fun useGpu(context: Context, target: GpuCheck.Target): Boolean

True when target should run on the GPU. Checks on first call (up to two minutes).