From 94453cfc1aab017e5c0ec3be7e80a08789823f99 Mon Sep 17 00:00:00 2001 From: Matthias Cremon Date: Mon, 7 Apr 2025 14:15:28 -0700 Subject: [PATCH] Fix naming convention in quantizer (#9941) Summary: As titled. I mixed up (a)symmetric and (un)signedness. Differential Revision: D72594670 --- backends/cadence/aot/quantizer/quantizer.py | 44 ++++++++++----------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/backends/cadence/aot/quantizer/quantizer.py b/backends/cadence/aot/quantizer/quantizer.py index 62727985452..69c9518166b 100644 --- a/backends/cadence/aot/quantizer/quantizer.py +++ b/backends/cadence/aot/quantizer/quantizer.py @@ -43,7 +43,7 @@ from torch.ao.quantization.quantizer.composable_quantizer import ComposableQuantizer -act_qspec_asym8u = QuantizationSpec( +act_qspec_asym8s = QuantizationSpec( dtype=torch.int8, quant_min=-128, quant_max=127, @@ -52,7 +52,7 @@ observer_or_fake_quant_ctr=HistogramObserver.with_args(eps=2**-12), ) -wgt_qspec_asym8u = QuantizationSpec( +wgt_qspec_asym8s = QuantizationSpec( dtype=torch.int8, quant_min=-128, quant_max=127, @@ -61,7 +61,7 @@ observer_or_fake_quant_ctr=MinMaxObserver, ) -wgt_qspec_asym8s = QuantizationSpec( +wgt_qspec_sym8s = QuantizationSpec( dtype=torch.int8, quant_min=-128, quant_max=127, @@ -72,17 +72,17 @@ bias_qspec: Optional[QuantizationSpec] = None -qconfig_A8uW8u = QuantizationConfig( - act_qspec_asym8u, - act_qspec_asym8u, - wgt_qspec_asym8u, +qconfig_A8W8 = QuantizationConfig( + act_qspec_asym8s, + act_qspec_asym8s, + wgt_qspec_asym8s, None, ) -qconfig_A8uW8s = QuantizationConfig( - act_qspec_asym8u, - act_qspec_asym8u, - wgt_qspec_asym8s, +qconfig_A8W8sym = QuantizationConfig( + act_qspec_asym8s, + act_qspec_asym8s, + wgt_qspec_sym8s, None, ) @@ -189,15 +189,15 @@ def get_supported_operators(cls) -> List[OperatorConfig]: def get_cadence_default_quantizers() -> List[Quantizer]: return [ - CadenceAtenQuantizer(AddmmPattern(), qconfig_A8uW8u), - CadenceAtenQuantizer(BmmPattern(), qconfig_A8uW8u), - CadenceAtenQuantizer(Conv1dPattern(), qconfig_A8uW8s), - CadenceAtenQuantizer(Conv2dPattern(), qconfig_A8uW8s), - CadenceAtenQuantizer(LayerNormPattern(), qconfig_A8uW8u), - CadenceAtenQuantizer(LinearPattern(), qconfig_A8uW8u), - CadenceAtenQuantizer(MatmulPattern(), qconfig_A8uW8u), - CadenceAtenQuantizer(ReluPattern0(), qconfig_A8uW8u), - CadenceAtenQuantizer(ReluPattern1(), qconfig_A8uW8u), + CadenceAtenQuantizer(AddmmPattern(), qconfig_A8W8), + CadenceAtenQuantizer(BmmPattern(), qconfig_A8W8), + CadenceAtenQuantizer(Conv1dPattern(), qconfig_A8W8sym), + CadenceAtenQuantizer(Conv2dPattern(), qconfig_A8W8sym), + CadenceAtenQuantizer(LayerNormPattern(), qconfig_A8W8), + CadenceAtenQuantizer(LinearPattern(), qconfig_A8W8), + CadenceAtenQuantizer(MatmulPattern(), qconfig_A8W8), + CadenceAtenQuantizer(ReluPattern0(), qconfig_A8W8), + CadenceAtenQuantizer(ReluPattern1(), qconfig_A8W8), ] @@ -244,6 +244,6 @@ class CadenceWakeWordQuantizer(CadenceQuantizer): def __init__(self, quantizers: Optional[list[Quantizer]] = None) -> None: if quantizers is None: quantizers = get_cadence_default_quantizers() - quantizers.append(CadenceAtenQuantizer(AddPattern(), qconfig_A8uW8u)) - quantizers.append(CadenceAtenQuantizer(CatPattern(), qconfig_A8uW8u)) + quantizers.append(CadenceAtenQuantizer(AddPattern(), qconfig_A8W8)) + quantizers.append(CadenceAtenQuantizer(CatPattern(), qconfig_A8W8)) super().__init__(quantizers)