# ConverterError: Flex delegate is not enabled; some ops are not supported by the TFLite runtime

- **ID:** `tensorflow/tflite-flex-op-delegate`
- **Domain:** tensorflow
- **Category:** build_error
- **Error Code:** `TFD`
- **Verification:** ai_generated
- **Fix Rate:** 85%

## Root Cause

Model uses TensorFlow ops not natively supported by TFLite, and the converter is not configured to fall back to Flex ops.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| tensorflow 2.13 | active | — | — |
| tensorflow 2.14 | active | — | — |
| tensorflow 2.15 | active | — | — |
| tflite 2.13 | active | — | — |
| tflite 2.14 | active | — | — |

## Workarounds

1. **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()** (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()
   ```
2. **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.** (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.
   ```

## Dead Ends

- **Adding allow_custom_ops=True without enabling Flex** — Custom ops are different from Flex ops; this flag only allows custom ops, not TensorFlow ops via Flex. (80% fail)
- **Using tf.lite.TFLiteConverter.from_keras_model instead of from_saved_model** — The converter source does not affect op support; Flex must be explicitly enabled regardless. (95% fail)
