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).
Supported on iOS, macOS, Linux and Windows. Not on Android: Android flex was removed in flutter_litert 4.0.0 because LiteRT 2.x has no flex delegate. There isAvailable is false and create throws. Reconvert the model to LiteRT built-in ops, or stay on flutter_litert 3.10.x with flutter_litert_flex 1.3.0.
Add flutter_litert_flex
to your pubspec.yaml to bundle the native library on supported
platforms:
dependencies:
flutter_litert: ^4.1.0
flutter_litert_flex: ^2.1.0
Then create the delegate. The async create works on every supported platform:
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
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
- debugIsAndroidOverride ↔ bool?
-
Overrides the Android check in tests. Null uses Platform.isAndroid.
getter/setter pair
- isAvailable → bool
-
Whether the Flex delegate library is available.
no setter
Static Methods
-
create(
) → Future< FlexDelegate> - Creates a FlexDelegate asynchronously.