TFD
tensorflow
build_error
ai_generated
true
ConverterError: Flex delegate is not enabled; some ops are not supported by the TFLite runtime
ID: tensorflow/tflite-flex-op-delegate
85%Fix Rate
87%Confidence
1Evidence
2023-11-05First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| tensorflow 2.13 | active | — | — | — |
| tensorflow 2.14 | active | — | — | — |
| tensorflow 2.15 | active | — | — | — |
| tflite 2.13 | active | — | — | — |
| tflite 2.14 | active | — | — | — |
Root Cause
Model uses TensorFlow ops not natively supported by TFLite, and the converter is not configured to fall back to Flex ops.
generic中文
模型使用了 TFLite 原生不支持的 TensorFlow 操作,且转换器未配置为回退到 Flex 操作。
Official Documentation
https://www.tensorflow.org/lite/guide/ops_selectWorkarounds
-
90% success Enable Flex ops in the converter: converter = tf.lite.TFLiteConverter.from_saved_model('model_dir'); converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS, tf.lite.OpsSet.SELECT_TF_OPS]; tflite_model = converter.convert()
Enable Flex ops in the converter: converter = tf.lite.TFLiteConverter.from_saved_model('model_dir'); converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS, tf.lite.OpsSet.SELECT_TF_OPS]; tflite_model = converter.convert() -
70% success Replace unsupported ops with TFLite-compatible alternatives (e.g., replace tf.nn.softmax_cross_entropy_with_logits with tf.keras.losses.CategoricalCrossentropy). Then retry conversion without Flex.
Replace unsupported ops with TFLite-compatible alternatives (e.g., replace tf.nn.softmax_cross_entropy_with_logits with tf.keras.losses.CategoricalCrossentropy). Then retry conversion without Flex.
中文步骤
Enable Flex ops in the converter: converter = tf.lite.TFLiteConverter.from_saved_model('model_dir'); converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS, tf.lite.OpsSet.SELECT_TF_OPS]; tflite_model = converter.convert()Replace unsupported ops with TFLite-compatible alternatives (e.g., replace tf.nn.softmax_cross_entropy_with_logits with tf.keras.losses.CategoricalCrossentropy). Then retry conversion without Flex.
Dead Ends
Common approaches that don't work:
-
Adding allow_custom_ops=True without enabling Flex
80% fail
Custom ops are different from Flex ops; this flag only allows custom ops, not TensorFlow ops via Flex.
-
Using tf.lite.TFLiteConverter.from_keras_model instead of from_saved_model
95% fail
The converter source does not affect op support; Flex must be explicitly enabled regardless.