react-native-executorch
Version:
An easy way to run AI models in React Native with ExecuTorch
15 lines (14 loc) • 631 B
JavaScript
import { BaseNonStaticModule } from '../BaseNonStaticModule';
import { ResourceFetcher } from '../../utils/ResourceFetcher';
export class ExecutorchModule extends BaseNonStaticModule {
async load(modelSource, onDownloadProgressCallback = () => { }) {
const paths = await ResourceFetcher.fetch(onDownloadProgressCallback, modelSource);
if (paths === null || paths.length < 1) {
throw new Error('Download interrupted.');
}
this.nativeModule = global.loadExecutorchModule(paths[0] || '');
}
async forward(inputTensor) {
return await this.forwardET(inputTensor);
}
}