{
  "id": "tensorflow/tflite-converter-unsupported-op",
  "signature": "ConverterError: Quantization not supported for op 'Cumsum'. Op has no registered quantized kernel.",
  "signature_zh": "转换器错误：操作 'Cumsum' 不支持量化。该操作没有注册的量化内核。",
  "regex": "Quantization not supported for op.*No registered quantized kernel",
  "domain": "tensorflow",
  "category": "build_error",
  "subcategory": null,
  "root_cause": "During TFLite conversion with quantization enabled, an operation (e.g., Cumsum, Gather, or TopK) does not have a quantized kernel implementation, causing the converter to fail.",
  "root_cause_type": "generic",
  "root_cause_zh": "在启用量化的 TFLite 转换过程中，某个操作（例如 Cumsum、Gather 或 TopK）没有量化的内核实现，导致转换器失败。",
  "versions": [
    {
      "version": "TensorFlow 2.7.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "TFLite 2.7.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "This may avoid the quantization error but results in a non-optimized model, losing the benefits of quantization (size reduction, speed).",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Manual replacement is error-prone and may change model behavior; also, the custom op may not be supported in TFLite either.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Even in the latest versions, some ops still lack quantized kernels; upgrading alone does not guarantee support.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Use selective quantization: apply quantization only to supported ops by using `converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS_INT8]` and exclude unsupported ops by falling back to float. Alternatively, use `converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS, tf.lite.OpsSet.SELECT_TF_OPS]` to allow select TensorFlow ops.",
      "success_rate": 0.85,
      "how": "Use selective quantization: apply quantization only to supported ops by using `converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS_INT8]` and exclude unsupported ops by falling back to float. Alternatively, use `converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS, tf.lite.OpsSet.SELECT_TF_OPS]` to allow select TensorFlow ops.",
      "condition": "",
      "sources": []
    },
    {
      "action": "If the unsupported op is critical, convert the model without quantization (set optimizations=[]) and then apply post-training quantization using a representative dataset that avoids the op, or use full-integer quantization with fallback.",
      "success_rate": 0.8,
      "how": "If the unsupported op is critical, convert the model without quantization (set optimizations=[]) and then apply post-training quantization using a representative dataset that avoids the op, or use full-integer quantization with fallback.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Rewrite the model to avoid the unsupported op. For example, replace tf.math.cumsum with a loop or a different algorithm that uses supported ops like Add and Scan.",
      "success_rate": 0.7,
      "how": "Rewrite the model to avoid the unsupported op. For example, replace tf.math.cumsum with a loop or a different algorithm that uses supported ops like Add and Scan.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "使用选择性量化：仅对支持的操作应用量化，通过设置 `converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS_INT8]`，并对不支持的操作回退到浮点。或者使用 `converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS, tf.lite.OpsSet.SELECT_TF_OPS]` 允许选择 TensorFlow 操作。",
    "如果不受支持的操作是关键性的，则在不量化的情况下转换模型（设置 optimizations=[]），然后使用避免该操作的代表性数据集应用训练后量化，或使用带有回退的全整数量化。",
    "重写模型以避免不受支持的操作。例如，用循环或使用支持的操作（如 Add 和 Scan）的不同算法替换 tf.math.cumsum。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://www.tensorflow.org/lite/performance/post_training_quantization#full_integer_quantization",
  "official_doc_section": null,
  "error_code": "ETQU",
  "verification_tier": "ai_generated",
  "confidence": 0.86,
  "fix_success_rate": 0.8,
  "resolvable": "partial",
  "first_seen": "2023-05-18",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}