ExecuTorchModel class abstract
High-level wrapper for an ExecuTorch model instance
This is the main API for loading, managing, and running inference on ExecuTorch models. It provides a consistent interface across all platforms.
Runs on Android, iOS, macOS, Windows, and Linux through dart:ffi with
native assets. There is no web implementation here — for web, use
package:executorch_flutter.
Usage Pattern
Loading from a file (native platforms):
final model = await ExecuTorchModel.load('/path/to/model.pte');
final outputs = await model.forward(inputs);
await model.dispose();
Flutter applications can load from the asset bundle with
loadModelFromAsset from
package:executorch_flutter/executorch_flutter.dart.
Loading from Bytes:
import 'dart:io';
final bytes = await File('/path/to/model.pte').readAsBytes();
final model = await ExecuTorchModel.loadFromBytes(bytes);
final outputs = await model.forward(inputs);
await model.dispose();
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- isDisposed → bool
-
Whether this model has been disposed
no setter
- modelId → String
-
Unique identifier for this model instance
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
dispose(
) → Future< void> - Dispose this model and free its resources
-
forward(
List< TensorData> inputs) → Future<List< TensorData> > - Execute inference on the model
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
load(
String filePath) → Future< ExecuTorchModel> - Load an ExecuTorch model from a file path (static factory)
-
loadFromBytes(
Uint8List modelBytes) → Future< ExecuTorchModel> - Load an ExecuTorch model from bytes