Skip to content

Commit fc48e03

Browse files
committed
Add check to only annotate dq conv2d
1 parent 7054f2e commit fc48e03

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

backends/xnnpack/quantizer/xnnpack_quantizer_utils.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
"propagate_annotation",
4343
]
4444

45+
from pytorch.ao.test.dtypes.test_bitpacking import dimensions
46+
4547

4648
# In the absence of better name, just winging it with QuantizationConfig
4749
@dataclass(eq=True, frozen=True)
@@ -323,6 +325,17 @@ def _do_annotate_conv(
323325
assert isinstance(weight, Node)
324326
input_qspec_map[weight] = get_weight_qspec(quantization_config)
325327

328+
# Only annotate dynamically quantized conv if it's 2D
329+
if (
330+
quantization_config
331+
and quantization_config.input_activation
332+
and quantization_config.input_activation.is_dynamic
333+
):
334+
weight_val = weight.meta.get("val", None)
335+
weight_shape = getattr(weight_val, "shape", None)
336+
if weight_shape is not None and len(weight_shape) != 4:
337+
continue
338+
326339
# adding weight node to the partition as well
327340
partition = [conv_node, conv_node.args[1]]
328341

0 commit comments

Comments
 (0)