Skip to content

Commit ec31735

Browse files
authored
Enable QuantFusionPass in compiler pipeline (pytorch#19728) (pytorch#19728)
Summary: Both and Cadence now use the shared `QuantFusionPass` from `compiler_funcs.py`. - `QuantFusionPass` in `compiler_funcs.py` iterates patterns, matches `anchor_ops()`, calls `fuse()` on each match, with debug logging and dead code elimination - Cadence: `compiler.py` now uses `QuantFusionPass` instead of the old `QuantFusion` isinstance switch - Removed Cadence `compiler` target's dep on `:fusion_pass` (no longer imported) Reviewed By: DrJessop Differential Revision: D105728219
1 parent bd24e79 commit ec31735

2 files changed

Lines changed: 4 additions & 6 deletions

File tree

backends/cadence/aot/BUCK

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ fbcode_target(_kind = runtime.python_library,
4444
":compiler_funcs",
4545
":utils",
4646
"//caffe2:torch",
47-
"//executorch/backends/cadence/aot/quantizer:fusion_pass",
4847
"//executorch/backends/cadence/aot/quantizer/passes:fuse_ops",
4948
"//executorch/backends/cadence/aot/quantizer:quantizer",
5049
"//executorch/backends/transforms:decompose_sdpa",
@@ -65,7 +64,6 @@ fbcode_target(_kind = runtime.python_library,
6564
":replace_ops",
6665
":utils",
6766
"//caffe2:torch",
68-
"//executorch/backends/cadence/aot/quantizer:fusion_pass",
6967
"//executorch/backends/cadence/aot/quantizer:quantizer",
7068
"//executorch/backends/cadence/runtime:runtime",
7169
"//executorch/backends/transforms:decompose_sdpa",

backends/cadence/aot/compiler.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
import torch
1515
from executorch.backends.cadence.aot.compiler_funcs import (
1616
prepare as prepare_fn,
17+
QuantFusionPass,
1718
QuantizedInputWrapper,
1819
trace as trace_fn,
1920
)
2021
from executorch.backends.cadence.aot.memory_planning import (
2122
CadenceMemoryPlanning,
2223
print_memory_planning_info,
2324
)
24-
from executorch.backends.cadence.aot.quantizer.fusion_pass import QuantFusion
2525
from executorch.backends.cadence.aot.quantizer.passes.fuse_ops import FuseQATConvBN
2626
from executorch.backends.cadence.aot.quantizer.quantizer import (
2727
CadenceDefaultQuantizer,
@@ -154,9 +154,9 @@ def apply_pre_edge_transform_passes(
154154
quantizer: CadenceQuantizer,
155155
) -> ExportedProgram:
156156
"""
157-
Apply pre-edge transform passes including QuantFusion and torch ops passes.
157+
Apply pre-edge transform passes including QuantFusionPass and torch ops passes.
158158
This mirrors the Cadence AOT compiler flow:
159-
1. QuantFusion - fuses dq->op->q patterns
159+
1. QuantFusionPass - fuses dq->op->q patterns
160160
2. apply_torch_ops_passes - applied just before to_edge()
161161
162162
The quantizer must be the same as the one used to convert the model.
@@ -169,7 +169,7 @@ def apply_pre_edge_transform_passes(
169169
PassManager(
170170
[
171171
FuseQATConvBN(converted_program),
172-
QuantFusion(patterns),
172+
QuantFusionPass(patterns),
173173
]
174174
)(converted_program.graph_module)
175175

0 commit comments

Comments
 (0)