{
  "id": "tensorflow/tflite-flex-op-delegate",
  "signature": "ConverterError: Flex delegate is not enabled; some ops are not supported by the TFLite runtime",
  "signature_zh": "转换器错误：Flex 委托未启用；某些操作不受 TFLite 运行时支持",
  "regex": "Flex delegate is not enabled; some ops are not supported by the TFLite runtime",
  "domain": "tensorflow",
  "category": "build_error",
  "subcategory": null,
  "root_cause": "Model uses TensorFlow ops not natively supported by TFLite, and the converter is not configured to fall back to Flex ops.",
  "root_cause_type": "generic",
  "root_cause_zh": "模型使用了 TFLite 原生不支持的 TensorFlow 操作，且转换器未配置为回退到 Flex 操作。",
  "versions": [
    {
      "version": "tensorflow 2.13",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "tensorflow 2.14",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "tensorflow 2.15",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "tflite 2.13",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "tflite 2.14",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Adding allow_custom_ops=True without enabling Flex",
      "why_fails": "Custom ops are different from Flex ops; this flag only allows custom ops, not TensorFlow ops via Flex.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "Using tf.lite.TFLiteConverter.from_keras_model instead of from_saved_model",
      "why_fails": "The converter source does not affect op support; Flex must be explicitly enabled regardless.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "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()",
      "success_rate": 0.9,
      "how": "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()",
      "condition": "",
      "sources": []
    },
    {
      "action": "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.",
      "success_rate": 0.7,
      "how": "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.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "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."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://www.tensorflow.org/lite/guide/ops_select",
  "official_doc_section": null,
  "error_code": "TFD",
  "verification_tier": "ai_generated",
  "confidence": 0.87,
  "fix_success_rate": 0.85,
  "resolvable": "true",
  "first_seen": "2023-11-05",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}