encoderBackendWireName function

String encoderBackendWireName(
  1. BackendKind? encoderBackend
)

Wire name for an ENCODER backend (vision / audio), defaulting to cpu when unset. Shared by both because their defaulting is identical (null → cpu).

The LLM engine passes what its load plan chose from the bundle (the section's backend_constraint, else the NPU it is compiled for, else CPU), so null reaches here only for a file the plan could not read. CPU is the safe value then: the VISION graph carries STABLEHLO_COMPOSITE ops the Metal (iOS/macOS) and WebGPU (Windows/Linux) LiteRT delegates cannot prepare — it hard-fails at conversation_create with no backend fallback (LiteRT-LM#2461, open upstream) — and the published Gemma 4 and Gemma 3n AUDIO encoders declare backend_constraint cpu.

Implementation

String encoderBackendWireName(BackendKind? encoderBackend) =>
    encoderBackend == null ? 'cpu' : ffiBackendWireName(encoderBackend);