[quant][graphmode][fx] Keep linear op unchanged when qconfig is not supported (#48067)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/48067
Test Plan: Imported from OSS
Reviewed By: supriyar
Differential Revision: D25008463
fbshipit-source-id: d0bfc6bf8d544824d0a55cd4bcd1f9301d75c935
diff --git a/torch/quantization/fx/quantization_patterns.py b/torch/quantization/fx/quantization_patterns.py
index 62eba00..ab62c30 100644
--- a/torch/quantization/fx/quantization_patterns.py
+++ b/torch/quantization/fx/quantization_patterns.py
@@ -294,8 +294,13 @@
]
qconfig = quantizer.qconfig_map[node.name]
dtypes = get_qconfig_dtypes(qconfig)
- assert dtypes in supported_dtypes, "qconfig dtype pair not supported:" \
- " {}, supported dtypes are: {}".format(dtypes, supported_dtypes)
+ if dtypes not in supported_dtypes:
+ warnings.warn(
+ "dtype combination: {} is not "
+ "supported by Linear "
+ "supported dtype combinations are: {}".format(dtypes, supported_dtypes))
+ return quantizer.quantized_graph.node_copy(node, load_arg(quantized=None))
+
activation_statically_quantized = activation_is_statically_quantized(qconfig)
# TODO: debug option for linear module
if self.linear_node.op == 'call_module':