|
13 | 13 | import torch
|
14 | 14 | from executorch.exir.dialects._ops import ops as exir_ops
|
15 | 15 | from executorch.exir.dialects.edge._ops import EdgeOpOverload
|
| 16 | +from executorch.exir.operator.util import _QUANT_PRIMITIVES |
| 17 | +from executorch.exir.passes.replace_aten_with_edge_pass import aten_to_edge |
16 | 18 | from torch._export.utils import (
|
17 | 19 | get_buffer,
|
18 | 20 | get_lifted_tensor_constant,
|
|
25 | 27 | from torch.export.exported_program import InputKind, InputSpec, TensorArgument
|
26 | 28 | from torch.utils import _pytree as pytree
|
27 | 29 |
|
28 |
| - |
29 | 30 | # Avoid propagating constants for `exir.ops.edge.aten.full.default`.
|
30 | 31 | # Propagating aten.full can significantly increase compiled model size.
|
31 | 32 | _DEFAULT_SKIP_TARGETS = {exir_ops.edge.aten.full.default}
|
32 | 33 |
|
33 | 34 | # Do not const prop quantization primitives
|
34 |
| -_QDQ_OPS = [ |
35 |
| - exir_ops.edge.quantized_decomposed.dequantize_per_channel.default, |
36 |
| - exir_ops.edge.quantized_decomposed.dequantize_per_tensor.default, |
37 |
| - exir_ops.edge.quantized_decomposed.dequantize_per_tensor.tensor, |
38 |
| - exir_ops.edge.quantized_decomposed.convert_element_type.no_fuse, |
39 |
| - exir_ops.edge.quantized_decomposed.quantize_per_tensor.default, |
40 |
| - exir_ops.edge.quantized_decomposed.quantize_per_tensor.tensor, |
41 |
| - exir_ops.edge.quantized_decomposed.quantize_per_channel.default, |
42 |
| - exir_ops.edge.quantized_decomposed.choose_qparams.tensor, |
43 |
| -] |
44 |
| -try: |
45 |
| - import torchao # noqa: F401 |
46 |
| - |
47 |
| - _QDQ_OPS.extend( |
48 |
| - [ |
49 |
| - exir_ops.edge.torchao.dequantize_affine.default, |
50 |
| - exir_ops.edge.torchao.quantize_affine.default, |
51 |
| - exir_ops.edge.torchao.choose_qparams_affine.default, |
52 |
| - ] |
53 |
| - ) |
54 |
| -except ImportError: |
55 |
| - pass |
56 |
| -_DEFAULT_SKIP_TARGETS.update(set(_QDQ_OPS)) |
| 35 | +_QUANT_PRIMITIVES_EDGE = [aten_to_edge(op) for op in _QUANT_PRIMITIVES] |
| 36 | +_DEFAULT_SKIP_TARGETS.update(set(_QUANT_PRIMITIVES_EDGE)) |
57 | 37 |
|
58 | 38 |
|
59 | 39 | _PRIMITIVE_TYPES = (
|
|
0 commit comments