Skip to content

Fix naming convention in quantizer #9941

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 8, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 22 additions & 22 deletions backends/cadence/aot/quantizer/quantizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
)

Expand Down Expand Up @@ -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),
]


Expand Down Expand Up @@ -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)
Loading