OrtSession class

Constructors

OrtSession.fromAddress(int address)
Creates a session from a pointer's address.
OrtSession.fromBuffer(Uint8List modelBuffer, OrtSessionOptions options)
Creates a session from buffer.
OrtSession.fromFile(File modelFile, OrtSessionOptions options)
Creates a session from a file.

Properties

address int
no setter
hashCode int
The hash code for this object.
no setterinherited
inputCount int
no setter
inputNames List<String>
no setter
outputCount int
no setter
outputNames List<String>
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

getMetadatas(String key) String
killAllIsolates() Future<void>
Kills all active isolates (both persistent and one-time). Useful for cleanup when you want to ensure all isolates are terminated.
killIsolate() Future<void>
Kills the persistent async isolate while keeping the session alive. The session can still be used for new inference runs after calling this. Next runAsync() will create a new isolate. Note: This only kills the persistent isolate, not one-time isolates.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
release() Future<void>
run(OrtRunOptions runOptions, Map<String, OrtValue> inputs, [List<String>? outputNames]) List<OrtValue?>
Performs inference synchronously.
runAsync(OrtRunOptions runOptions, Map<String, OrtValue> inputs, [List<String>? outputNames]) Future<List<OrtValue?>>?
Performs inference asynchronously. Uses a persistent isolate that stays alive for reuse across multiple calls. This is efficient for repeated inference as it avoids isolate creation overhead. To kill the isolate, call killIsolate() or release(). Default timeout is 5 seconds. Use runAsyncWithTimeout() for custom timeout.
runAsyncWithTimeout(OrtRunOptions runOptions, Map<String, OrtValue> inputs, Duration timeout, [List<String>? outputNames]) Future<List<OrtValue?>>?
Performs inference asynchronously with a custom timeout. Uses a persistent isolate that stays alive for reuse. If the isolate times out, it will be killed and recreated on next use.
runOnceAsync(OrtRunOptions runOptions, Map<String, OrtValue> inputs, [List<String>? outputNames]) Future<List<OrtValue?>>
Creates a new isolate for a single inference run. Each call creates a fresh isolate, allowing concurrent inference. The isolate is automatically killed after the inference completes. Useful for parallel inference or one-off async operations. Default timeout is 5 seconds. Use runOnceAsyncWithTimeout() for custom timeout.
runOnceAsyncWithTimeout(OrtRunOptions runOptions, Map<String, OrtValue> inputs, Duration timeout, [List<String>? outputNames]) Future<List<OrtValue?>>
Creates a timed isolate for a single inference run. Each call creates a fresh isolate, allowing concurrent inference. The isolate will timeout after the specified duration. The isolate is automatically killed after completion or timeout.
runParallelAsync(List<Map<String, OrtValue>> inputsList, OrtRunOptions runOptions, [List<String>? outputNames, Duration timeout = const Duration(seconds: 5)]) Future<List<List<OrtValue?>>>
Runs multiple inference operations in parallel using separate isolates. Each inference runs in its own isolate, allowing true parallel execution. All isolates are automatically cleaned up after completion. Returns a list of results in the same order as the input list.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited