Interpreter class

LiteRT interpreter for running inference on a model.

Constructors

Interpreter.fromAddress(int address, {bool allocated = true, bool deleted = false, bool hasActiveDelegate = false})
Creates interpreter from an address.
factory
Interpreter.fromBuffer(Uint8List buffer, {InterpreterOptions? options})
Creates interpreter from a buffer.
factory
Interpreter.fromFile(File modelFile, {InterpreterOptions? options})
Creates Interpreter from a model file
factory

Properties

address int
Returns the address to the interpreter
no setter
hasActiveDelegate bool
Whether interpreter creation successfully applied a hardware delegate.
no setter
hashCode int
The hash code for this object.
no setterinherited
isAllocated bool
Whether tensors have been allocated.
no setter
isDeleted bool
Whether this interpreter has been closed.
no setter
lastInferenceDurationMicroseconds int
Duration of the last inference call in microseconds.
no setter
lastNativeInferenceDurationMicroSeconds int
Duration of the last native inference call in microseconds.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
signatureCount int
Returns the number of signatures defined in the model.
no setter
signatureKeys List<String>
Returns the keys of all signatures defined in the model.
no setter

Methods

allocateTensors() → void
Updates allocations for all tensors.
close() → void
Destroys the interpreter instance.
getInputIndex(String opName) int
Gets index of an input given the op name of the input.
getInputTensor(int index) Tensor
Gets the input Tensor for the provided input index.
getInputTensors() List<Tensor>
Gets all input tensors associated with the model.
getOutputIndex(String opName) int
Gets index of an output given the op name of the output.
getOutputTensor(int index) Tensor
Gets the output Tensor for the provided output index.
getOutputTensors() List<Tensor>
Gets all output tensors associated with the model.
getSignatureKey(int index) String
Returns the key (name) of the signature at index.
getSignatureRunner(String signatureKey) SignatureRunner
Returns a SignatureRunner for the signature identified by signatureKey.
getVariableTensor(int index) Tensor
Gets the variable (trainable) tensor at the given index.
getVariableTensorCount() int
Returns the number of variable (trainable) tensors in the model.
invoke() → void
Runs inference for the loaded graph.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
resetVariableTensors() → void
Resets all variable tensors to their default values.
resizeInputTensor(int tensorIndex, List<int> shape) → void
Resize input tensor for the given tensor index. allocateTensors must be called again afterward.
run(Object input, Object output) → void
Run for single input and output
runForMultipleInputs(List<Object> inputs, Map<int, Object> outputs) → void
Run for multiple inputs and outputs
runInference(List<Object> inputs) → void
Just run inference
toString() String
A string representation of this object.
inherited

Operators

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

Static Properties

version String
Returns the LiteRT runtime version string.
no setter

Static Methods

fromAsset(String assetName, {InterpreterOptions? options}) Future<Interpreter>
Creates interpreter from a assetName
fromBytes(Uint8List bytes, {InterpreterOptions? options}) Future<Interpreter>
Creates an interpreter from raw model bytes.