runtimeModelFile function

RuntimeFile runtimeModelFile(
  1. String modelPath, [
  2. Map<String, RuntimeFile> runtimeFiles = prebuiltRuntimeFiles
])

Finds modelPath in the published runtime-file catalog.

Implementation

RuntimeFile runtimeModelFile(
  String modelPath, [
  Map<String, RuntimeFile> runtimeFiles = prebuiltRuntimeFiles,
]) {
  final name = runtimeModelName(modelPath);
  final file = runtimeFiles[name];
  if (file == null) {
    throw StateError('The runtime release has no fonnx model named $name.');
  }
  if (file.name != name) {
    throw StateError(
      'Runtime model catalog key $name describes ${file.name} instead.',
    );
  }
  return file;
}