CompiledModel class

LiteRT Next CompiledModel inference API.

Properties

accelerators → Set<Accelerator>
Accelerators this model was compiled with.
no setter
didFallback → bool
Whether construction retried or narrowed the accelerator selection.
no setter
hashCode → int
The hash code for this object.
no setterinherited
inputByteSizes → List<int>
Byte size of each input tensor buffer.
no setter
inputCount → int
Number of model input tensors.
no setter
isFullyAccelerated → bool
Whether the whole graph runs on a selected hardware accelerator.
no setter
outputByteSizes → List<int>
Byte size of each output tensor buffer.
no setter
outputCount → int
Number of model output tensors.
no setter
requestedAccelerators → Set<Accelerator>
Accelerators requested before any complete fallback.
no setter
requestedConfig → CompiledModelConfig?
Policy configuration used to construct this model.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
tensorBufferMode → TensorBufferMode
Tensor buffer allocation mode used by this model.
no setter

Methods

close() → void
Releases native CompiledModel resources.
dispatch() → void
Runs inference using inputs previously written with writeInput.
dispatchAsync() → Future<void>
Runs inference asynchronously using inputs previously written with writeInput.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
readOutput<R>(int index, R read(Float32List output)) → R
Reads output index directly from a host-memory tensor buffer.
run(List<Float32List> inputs) → List<Float32List>
Runs inference with Float32 input tensors and returns Float32 outputs.
runAsync(List<Float32List> inputs) → Future<List<Float32List>>
Runs inference asynchronously when the selected accelerator supports it.
toString() → String
A string representation of this object.
inherited
writeInput(int index, void write(Float32List input)) → void
Writes input index directly into a host-memory tensor buffer.

Operators

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

Static Methods

fromBuffer(Uint8List bytes, {Set<Accelerator> accelerators = const {Accelerator.cpu}, Precision precision = Precision.fp32, TensorBufferMode tensorBufferMode = TensorBufferMode.managed}) → CompiledModel
Creates a compiled model from model bytes.
fromBufferAsync(Uint8List bytes, {Set<Accelerator> accelerators = const {Accelerator.cpu}, Precision precision = Precision.fp32, TensorBufferMode tensorBufferMode = TensorBufferMode.managed}) → Future<CompiledModel>
Creates a compiled model from model bytes without requiring synchronous compilation.
fromBufferWithConfig(Uint8List bytes, {CompiledModelConfig config = const CompiledModelConfig.auto(), void onFallback(Object error)?}) → CompiledModel
Creates a policy-configured model from model bytes.
fromBufferWithConfigAsync(Uint8List bytes, {CompiledModelConfig config = const CompiledModelConfig.auto(), void onFallback(Object error)?}) → Future<CompiledModel>
Creates a policy-configured model from bytes without requiring synchronous compilation.
fromBufferWithGpuFallback(Uint8List bytes, {bool forceCpu = false, Precision precision = Precision.fp32, TensorBufferMode tensorBufferMode = TensorBufferMode.managed, void onFallback(Object error)?}) → CompiledModel
Creates a compiled model from bytes, preferring GPU with a CPU fallback.
fromBufferWithGpuFallbackAsync(Uint8List bytes, {bool forceCpu = false, Precision precision = Precision.fp32, TensorBufferMode tensorBufferMode = TensorBufferMode.managed, void onFallback(Object error)?}) → Future<CompiledModel>
Creates a compiled model from bytes, preferring GPU with a CPU fallback, without requiring synchronous compilation.
fromFile(String path, {Set<Accelerator> accelerators = const {Accelerator.cpu}, Precision precision = Precision.fp32, TensorBufferMode tensorBufferMode = TensorBufferMode.managed}) → CompiledModel
Creates a compiled model from a model file.
fromFileWithConfig(String path, {CompiledModelConfig config = const CompiledModelConfig.auto(), void onFallback(Object error)?}) → CompiledModel
Creates a policy-configured model from a model file.