Skip to content

Commit 80ee65b

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. Reviewed By: hsharma35 Differential Revision: D88109865
1 parent 42e3222 commit 80ee65b

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

backends/cadence/aot/remove_ops.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -566,13 +566,17 @@ 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()
574+
if modified:
575+
graph_module.graph.eliminate_dead_code()
576+
graph_module.recompile()
577+
return super().call(graph_module)
574578

575-
return super().call(graph_module)
579+
return PassResult(graph_module, False)
576580

577581
def visit(
578582
self,

0 commit comments

Comments
 (0)