tryReadBundleActivationDeclaration function
litertlmDeclaresActivationType for the file at modelPath, with a file it
cannot read or parse returned as BundleActivationRead.error instead of
thrown, as tryReadBundleSampler does: the engine's own load reports a
real failure, and what this decides is only a default. A caller must say
that the answer is unknown, because the model then runs at the GPU default.
Implementation
Future<BundleActivationRead> tryReadBundleActivationDeclaration(
String modelPath,
) async {
try {
final file = await File(modelPath).open();
try {
final headerEnd = litertlmHeaderEnd(await _readExactly(file, 0, 32));
return (
declaresKey: litertlmDeclaresActivationType(
await _readExactly(file, 32, headerEnd - 32),
),
error: null,
);
} finally {
await file.close();
}
} on FileSystemException catch (e) {
return (declaresKey: null, error: 'FileSystemException: ${e.message}');
} on FormatException catch (e) {
return (declaresKey: null, error: 'FormatException: ${e.message}');
}
}