From c9493ea147bc4000de8a9e8a6c6d289b45d53fb4 Mon Sep 17 00:00:00 2001 From: Google AI Edge Date: Thu, 6 Jun 2024 17:34:28 -0700 Subject: [PATCH] No public description PiperOrigin-RevId: 641074571 --- .../algorithms/uniform_quantize/naive_min_max_quantize.py | 4 +++- ai_edge_quantizer/algorithms/utils/min_max_quantize_utils.py | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ai_edge_quantizer/algorithms/uniform_quantize/naive_min_max_quantize.py b/ai_edge_quantizer/algorithms/uniform_quantize/naive_min_max_quantize.py index a77ac3a..e164469 100644 --- a/ai_edge_quantizer/algorithms/uniform_quantize/naive_min_max_quantize.py +++ b/ai_edge_quantizer/algorithms/uniform_quantize/naive_min_max_quantize.py @@ -30,7 +30,9 @@ def check_op_quantization_config( """ if op_quant_config.weight_tensor_config.dtype != qtyping.TensorDataType.INT: raise ValueError( - "Weights need to have integer type for naive min/max quantization." + "Weights need to have integer type for min/max uniform quantization. If" + " you wish to perform float casting quantization (e.g., fp16 weight" + " only), please set algorithm key as 'float_casting'." ) execution_mode = op_quant_config.execution_mode if execution_mode == _OpExecutionMode.WEIGHT_ONLY: diff --git a/ai_edge_quantizer/algorithms/utils/min_max_quantize_utils.py b/ai_edge_quantizer/algorithms/utils/min_max_quantize_utils.py index bab72d3..f656ccd 100644 --- a/ai_edge_quantizer/algorithms/utils/min_max_quantize_utils.py +++ b/ai_edge_quantizer/algorithms/utils/min_max_quantize_utils.py @@ -65,6 +65,8 @@ def check_srq_config( ) if act_config is None: raise ValueError("activation_tensor_config is required for SRQ.") + if act_config.dtype != qtyping.TensorDataType.INT: + raise ValueError("SRQ requires activation tensor to be int type.") if act_config.num_bits not in (8, 16): raise ValueError( f"Only int8/int16 activation SRQ is supported for op {op_name}."