From 19a9b159378ac5d8f8b93a1c9319b14ac3dc26ed Mon Sep 17 00:00:00 2001 From: Ekaterina Ignasheva Date: Tue, 4 Nov 2025 11:29:29 -0800 Subject: [PATCH] Unify reorder passes. (#15561) Summary: Pull Request resolved: https://github.com/pytorch/executorch/pull/15561 Reviewed By: ethansfng, DrJessop Differential Revision: D85264577 --- backends/cadence/aot/reorder_ops.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/backends/cadence/aot/reorder_ops.py b/backends/cadence/aot/reorder_ops.py index 675c8e6cecd..0026c35ed57 100644 --- a/backends/cadence/aot/reorder_ops.py +++ b/backends/cadence/aot/reorder_ops.py @@ -820,9 +820,7 @@ def call(self, graph_module: torch.fx.GraphModule) -> PassResult: return super().call(self.graph_module) -# The following class consolidates functions to reoder ops (i.e., either hoist -# or sink some ops in the graph). -class CadenceReorderOpsInGraph: +class CommonReorderPasses: passes = [ # Hoist/sink nodes closer to their SSA def/use HoistOpsCloserToDefPass, @@ -832,6 +830,13 @@ class CadenceReorderOpsInGraph: # nodes closer to their def/use. AdvanceQuantizeOpAboveDefChainPass, PostponeDequantizeOpBelowUseChainPass, + ] + + +# The following class consolidates functions to reoder ops (i.e., either hoist +# or sink some ops in the graph). +class CadenceReorderOpsInGraph: + passes = CommonReorderPasses.passes + [ # These passes work on branches instead of linear chains to advance # quantize op beyond their def. AdvanceQuantizeOpAboveDefInBranchPass,