react-native-executorch
Version:
An easy way to run AI models in react native with ExecuTorch
23 lines (22 loc) • 700 B
JavaScript
import { fetchResource } from '../utils/fetchResource';
import { getError } from '../Error';
export class BaseModule {
static onDownloadProgressCallback = _downloadProgress => {};
static async load(modelSource) {
if (!modelSource) return;
try {
const fileUri = await fetchResource(modelSource, this.onDownloadProgressCallback);
await this.module.loadModule(fileUri);
} catch (e) {
throw new Error(getError(e));
}
}
static async forward(..._) {
throw new Error('The forward method is not implemented.');
}
static onDownloadProgress(callback) {
this.onDownloadProgressCallback = callback;
}
}
//# sourceMappingURL=BaseModule.js.map
;