Type Alias: Model
Model =
object
Defined in: core/model.ts:38
A compiled, ready-to-run ExecuTorch model loaded into native memory.
A Model exposes the raw ExecuTorch execution interface. It is intentionally
low-level and domain-agnostic; higher-level task pipelines build on top of
this interface.
Obtain a Model instance via the loadModel function. When the model
is no longer needed, call Model.dispose to release native memory.
Properties
backends
readonlybackends:Record<string, readonlystring[]>
Defined in: core/model.ts:44
ExecuTorch backends used by a given method.
path
readonlypath:string
Defined in: core/model.ts:40
The local filesystem path of the .pte model file.
schema
readonlyschema:ModelSpec<ConcreteDim>
Defined in: core/model.ts:42
The exported schema of this model.
Methods
dispose()
dispose():
void
Defined in: core/model.ts:70
Releases the native ExecuTorch model and frees all associated resources.
After calling dispose, this model instance must not be used again.
Returns
void
execute()
execute(
methodName,inputs,outputTensors):ModelOutput[]
Defined in: core/model.ts:63
Executes a named model method synchronously.
Inputs are provided in the same order as the method's input slots. Output
tensors must be pre-allocated and passed in outputTensors; the runtime
writes results into them in-place and also returns them as the function
result.
Parameters
methodName
string
The exported method to run (e.g. 'forward').
inputs
The list of input values to pass to the method, in order.
outputTensors
Tensor[]
Pre-allocated tensors for the method to write outputs into, in order.
Returns
Throws
Thrown with code EXECUTION_FAILED if
inference fails, SCHEMA_MISMATCH if runtime constraints fail,
RESOURCE_BUSY if the model or a tensor is in use, RESOURCE_DISPOSED if
disposed, or INVALID_ARGUMENT if inputs or output placeholders are
invalid.