resolve

fun resolve(requested: ComputeBackend, available: Set<ComputeBackend>, allowFallback: Boolean = true): ComputeBackend(source)

Resolves a requested backend to a concrete backend (never AUTO) given the set of backends the engine can actually use on this device. CPU_ONLY is always treated as available.

Rules:

  1. AUTO resolves to the first entry of AUTO_PREFERENCE_ORDER contained in available.

  2. A concrete backend contained in available resolves to itself.

  3. Otherwise, if allowFallback is true, the fallback chain is walked until an available backend is found (ending at CPU_ONLY).

  4. If allowFallback is false, a BackendUnavailableException is thrown.

Parameters

available

backends supported by the engine on this device; AUTO entries are ignored.

Throws

if the requested backend is unavailable and fallback is disabled.