load method
Make id resident, paying the load cost now rather than on first use.
Only LoadOptions.backendPreferences's first entry (equivalently the
deprecated framework) reaches commons today; other placement knobs
are not yet carried by the native load ABI.
Throws SDKException when the model is unknown or fails to load.
Implementation
Future<LoadedModel> load(String id, {LoadOptions? options}) async {
final model = await get(id);
if (model == null) {
throw SDKException.modelNotFound(id);
}
await ModelGate.ensureLoaded(
modelId: id,
category: model.category,
options: options,
);
final preferences = options?.resolvedBackendPreferences ?? const [];
final requestedBackend = preferences.isEmpty ? null : preferences.first;
return LoadedModel(
id: id,
category: model.category,
requestedBackend: requestedBackend,
actualBackend: requestedBackend?.backend ?? model.framework,
closeHandler: unload,
);
}