FlexDelegate class

Flex delegate for running models that use SELECT_TF_OPS.

The Flex delegate enables TensorFlow operations that are not available as TFLite builtins. This is required for training models whose gradient ops cannot be expressed as builtins (e.g., Conv2D, BatchNormalization).

Add flutter_litert_flex to your pubspec.yaml to bundle the native library on supported native platforms:

dependencies:
  flutter_litert: ^3.2.2
  flutter_litert_flex: ^1.3.0

Then use the async constructor, which is required on Android and also works on the other supported native platforms:

final flex = await FlexDelegate.create();
final options = InterpreterOptions();
options.addDelegate(flex);
final interpreter = Interpreter.fromFile(model, options: options);
Implemented types

Constructors

FlexDelegate()
Creates a FlexDelegate for SELECT_TF_OPS support.
factory

Properties

base Pointer<TfLiteDelegate>
Get pointer to TfLiteDelegate
no setteroverride
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

delete() → void
Releases native Flex delegate resources.
override
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 Properties

isAvailable bool
Whether the Flex delegate library is available.
no setter

Static Methods

create() Future<FlexDelegate>
Creates a FlexDelegate asynchronously.