activeBackend property

PreferredBackend? get activeBackend

Backend this embedder actually uses, when known — the counterpart of InferenceModel.activeBackend, and the answer to getActiveEmbedder(preferredBackend:) that survives a release build.

Every native backend answers PreferredBackend.cpu whatever was asked: LiteRT because its GPU delegate returns all-zero vectors for EmbeddingGemma's int4 weights, ONNX because it appends no execution provider. So a caller who passed gpu can read here that it did not happen, instead of learning it from a debug-only log line.

Null on web, where the runtime picks for itself and does not report back: LiteRT.js selects per COMPILE (with per-operation delegation only in the JSPI partial case) and reports it through window.getLiteRtEmbeddingAccelerator() and getLiteRtEmbeddingFullyAccelerated() rather than here, and onnxruntime-web resolves ['webgpu', 'wasm'] in order.

Null also means "this implementation did not say" — a native engine whose forward-pass descriptor omitted activeBackend, or any implementation that does not override this getter. Treat null as unknown, never as CPU.

Defaulted rather than abstract so an existing SUBCLASS keeps compiling. implements does not inherit a default body, so those break regardless — which is why the CHANGELOG calls this breaking for engine authors. Override it wherever the answer is actually known.

Implementation

PreferredBackend? get activeBackend => null;