liteRtLmConstrainedDecodingRefusal function
String?
liteRtLmConstrainedDecodingRefusal({
- required String abi,
- required BackendKind backend,
- AndroidGpuFamily? androidGpu,
- NpuStack? npuVendor,
Why a response format is refused for a model loaded on backend on the
host abi, or null where that row passed (liteRtLmConstrainedDecodingRows).
Implementation
String? liteRtLmConstrainedDecodingRefusal({
required String abi,
required BackendKind backend,
AndroidGpuFamily? androidGpu,
NpuStack? npuVendor,
}) {
final row = liteRtLmConstrainedDecodingRow(
abi: abi,
backend: backend,
androidGpu: androidGpu,
npuVendor: npuVendor,
);
if (liteRtLmConstrainedDecodingRows.contains(row)) return null;
final detail = switch (backend) {
BackendKind.cpu => '$abi CPU',
BackendKind.gpu when abi == 'android_arm64' =>
'$abi GPU (${androidGpu?.name ?? 'unknown family'})',
BackendKind.gpu => '$abi GPU',
BackendKind.npu => '$abi NPU (${npuVendor?.label ?? 'unknown vendor'})',
};
return 'LiteRT-LM constrained decoding is refused on $detail until that row '
'passes the discriminating device run.';
}