{
  "id": "tensorflow/tflite-conversion-quantization-failed",
  "signature": "ConverterError: TFLite conversion failed: quantization for model layer 'conv2d' failed",
  "signature_zh": "ConverterError: TFLite 转换失败：模型层 'conv2d' 的量化失败",
  "regex": "ConverterError: TFLite conversion failed: quantization for model layer .* failed",
  "domain": "tensorflow",
  "category": "build_error",
  "subcategory": null,
  "root_cause": "The model contains operations or data types that are not supported by TFLite's post-training quantization, such as unsupported activations or dynamic ranges.",
  "root_cause_type": "generic",
  "root_cause_zh": "模型包含 TFLite 后训练量化不支持的操作或数据类型，例如不支持的激活函数或动态范围。",
  "versions": [
    {
      "version": "tensorflow 2.10",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "tensorflow 2.11",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "tensorflow 2.12",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "tflite 2.10",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "tflite 2.11",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The converter cannot handle the incompatible ops, leading to crashes.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The model structure may not support post-conversion quantization.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Use selective quantization: converter.optimizations = [tf.lite.Optimize.DEFAULT]; converter.target_spec.supported_types = [tf.float16]; then convert.",
      "success_rate": 0.85,
      "how": "Use selective quantization: converter.optimizations = [tf.lite.Optimize.DEFAULT]; converter.target_spec.supported_types = [tf.float16]; then convert.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Disable quantization for problematic layers: converter.optimizations = [] and convert without optimization.",
      "success_rate": 0.9,
      "how": "Disable quantization for problematic layers: converter.optimizations = [] and convert without optimization.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Replace unsupported ops with TFLite-compatible alternatives, e.g., replace tf.nn.relu6 with tf.nn.relu.",
      "success_rate": 0.8,
      "how": "Replace unsupported ops with TFLite-compatible alternatives, e.g., replace tf.nn.relu6 with tf.nn.relu.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Use selective quantization: converter.optimizations = [tf.lite.Optimize.DEFAULT]; converter.target_spec.supported_types = [tf.float16]; then convert.",
    "Disable quantization for problematic layers: converter.optimizations = [] and convert without optimization.",
    "Replace unsupported ops with TFLite-compatible alternatives, e.g., replace tf.nn.relu6 with tf.nn.relu."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://www.tensorflow.org/lite/performance/post_training_quantization",
  "official_doc_section": null,
  "error_code": "ETFLITE",
  "verification_tier": "ai_generated",
  "confidence": 0.84,
  "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": []
}