loadModel(
modelPath,options?):Model
Defined in: core/model.ts:126
Loads and compiles an ExecuTorch .pte model from the local filesystem.
The model is loaded synchronously into native memory. Prefer calling this inside a worklet runtime thread (via wrapAsync) to avoid blocking the JS thread during compilation.
string
The absolute local path to the .pte model file.
Optional loading configuration. See LoadModelOptions.
The compiled Model instance, ready for execution.
Thrown with code LOAD_FAILED if the model file
cannot be opened, has an invalid format, or fails native initialization.
const model = loadModel('/path/to/model.pte');
const input = tensor('float32', [1, 3, 224, 224]);
const output = tensor('float32', [1, 1000]);
try {
model.execute('forward', [input], [output]);
// ...
} finally {
input.dispose();
output.dispose();
model.dispose();
}