Skip to content

Commit 2eb7a5f

Browse files
Only support int8 and quant dtypes for quant operators (#11685)
Co-authored-by: Digant Desai <[email protected]>
1 parent e63e353 commit 2eb7a5f

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

backends/xnnpack/partition/config/xnnpack_config.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
from typing import List, Optional
1111

1212
import torch
13+
from executorch.backends.xnnpack.utils.quant_utils import (
14+
is_dequant,
15+
is_qparam,
16+
is_quant,
17+
)
1318
from executorch.exir.backend.canonical_partitioners.config_partitioner import (
1419
format_target_name,
1520
PartitionerConfig,
@@ -223,9 +228,18 @@ def _check_node_has_valid_dtype(self, node):
223228
valid_dtypes = {
224229
torch.float32,
225230
torch.float16,
226-
torch.int8,
227-
torch.qint8,
228231
}
232+
# Only allow int8 and quant dtypes for quant operations
233+
if is_quant(node) or is_dequant(node) or is_qparam(node):
234+
valid_dtypes.update(
235+
{
236+
torch.qint32,
237+
torch.qint8,
238+
torch.quint8,
239+
torch.int8,
240+
}
241+
)
242+
229243
if (
230244
node.op != "placeholder"
231245
and node.op != "call_function"

0 commit comments

Comments
 (0)