Skip to content

Commit 3aebc60

Browse files
mcr229facebook-github-bot
authored andcommitted
Check group size is divisible by 32
Summary: Currently when checking the per_channel_group quantization parameters we don't check that the group_size must be a multiple of 32. This constraint was added after we implemented the original checks here. Let's add multiple of 32 here. Reviewed By: digantdesai Differential Revision: D66131456
1 parent a0ac820 commit 3aebc60

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

backends/xnnpack/operators/node_visitor.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,9 @@ def _check_per_channel_group_params(
318318
), "For per_channel_group quant, num_groups and group_size must be > 0, but got num_groups: {num_groups}, group_size: {quant_params.group_size}"
319319
output_channels = dims[quant_params.axis]
320320
input_channels = dims[quant_params.axis ^ 1]
321+
assert (
322+
quant_params.group_size % 32 == 0
323+
), "Delegation to XNNPACK requires group_size to be a multiple of 32, but got {quant_params.group_size}"
321324
assert (
322325
output_channels == cast(torch.Tensor, quant_params.scale).shape[0]
323326
), "For per_channel_group quant, expecting output channels to match scale.shape[0], gut got: {output_channels}, scale.shape[0]: {quant_params.scale.shape[0]}"

0 commit comments

Comments
 (0)