Skip to content

Commit 5ceb786

Browse files
eigen-kfacebook-github-bot
authored andcommitted
Fix modified flag for RemovePermutesAroundElementwiseOps (pytorch#16047)
Summary: This change fixes an issue where the `RemovePermutesAroundElementwiseOps` pass was not correctly returning the modified flag to indicate whether the graph was changed during the optimization. The modified flag is crucial for the pass manager to determine if additional passes need to be run or if the optimization has reached a fixed point. Without properly returning this flag, the pass manager may not iterate correctly or may run unnecessary additional passes. Differential Revision: D88109865
1 parent 0ae9644 commit 5ceb786

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

backends/cadence/aot/remove_ops.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -566,13 +566,18 @@ def call(self, graph_module: torch.fx.GraphModule) -> PassResult:
566566
for node in subgraph.nodes:
567567
processed_nodes.add(node)
568568

569+
modified = False
569570
for subgraph in subgraphs_found:
570571
self.permute_subgraph(subgraph)
572+
modified = True
571573

572-
graph_module.graph.eliminate_dead_code()
573-
graph_module.recompile()
574574

575-
return super().call(graph_module)
575+
if modified:
576+
graph_module.graph.eliminate_dead_code()
577+
graph_module.recompile()
578+
return super().call(graph_module)
579+
580+
return PassResult(graph_module, False)
576581

577582
def visit(
578583
self,

0 commit comments

Comments
 (0)