TFD
tensorflow
build_error
ai_generated
true
转换器错误:Flex 委托未启用;某些操作不受 TFLite 运行时支持
ConverterError: Flex delegate is not enabled; some ops are not supported by the TFLite runtime
ID: tensorflow/tflite-flex-op-delegate
85%修复率
87%置信度
1证据数
2023-11-05首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| tensorflow 2.13 | active | — | — | — |
| tensorflow 2.14 | active | — | — | — |
| tensorflow 2.15 | active | — | — | — |
| tflite 2.13 | active | — | — | — |
| tflite 2.14 | active | — | — | — |
根因分析
模型使用了 TFLite 原生不支持的 TensorFlow 操作,且转换器未配置为回退到 Flex 操作。
English
Model uses TensorFlow ops not natively supported by TFLite, and the converter is not configured to fall back to Flex ops.
官方文档
https://www.tensorflow.org/lite/guide/ops_select解决方案
-
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.
无效尝试
常见但无效的做法:
-
Adding allow_custom_ops=True without enabling Flex
80% 失败
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% 失败
The converter source does not affect op support; Flex must be explicitly enabled regardless.