Skip to content

Commit b42d00c

Browse files
metascroyfacebook-github-bot
authored andcommitted
Remove RemoveRedundantViewCopyPass (#2464)
Summary: The RemoveRedundantViewCopyPass is unnecessary and can be replaced by NormalizeViewCopyBasePass + dead code elimintation. Reviewed By: larryliu0820 Differential Revision: D54866523
1 parent 660c9bd commit b42d00c

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

exir/passes/normalize_view_copy_base_pass.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,24 @@
1414
from torch.fx.passes.infra.pass_base import PassBase, PassResult
1515

1616

17-
def _is_view_copy(node: torch.fx.Node) -> bool:
17+
def _is_view_copy(node: torch.fx.Node) -> bool: # pyre-ignore[11]
1818
return node.op == "call_function" and node.target in (
1919
torch.ops.aten.view_copy.default,
2020
ops.edge.aten.view_copy.default,
2121
)
2222

2323

24-
class NormalizeViewCopyBasePass(PassBase):
24+
class NormalizeViewCopyBasePass(PassBase): # pyre-ignore[11]
2525
"""
2626
Point each view_copy to the first upstream non-view.
2727
2828
After this pass, the base of each view_copy is not a view_copy.
2929
3030
When combined with dead-code elimination, this pass removes redundant
3131
view_copy nodes.
32-
33-
TODO: replace RemoveRedundantViewCopyPass with NormalizeViewCopyBasePass + dead code elimination.
3432
"""
3533

36-
def call(self, graph_module: torch.fx.GraphModule) -> PassResult:
34+
def call(self, graph_module: torch.fx.GraphModule) -> PassResult: # pyre-ignore[11]
3735
n_updated = 0
3836
for module in graph_module.modules():
3937
if not isinstance(module, torch.fx.GraphModule):

exir/program/_program.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from executorch.exir.passes import (
2525
base_post_op_replace_passes,
2626
base_pre_op_replace_passes,
27+
dead_code_elimination_pass,
2728
EdgeToBackendOpsPass,
2829
MemoryFormatOpsPass,
2930
OpReplacePass,
@@ -626,6 +627,7 @@ def pre_memory_planning_passes(config: ExecutorchBackendConfig) -> List[PassType
626627
# pyre-ignore
627628
return [
628629
NormalizeViewCopyBasePass(),
630+
dead_code_elimination_pass,
629631
ReplaceViewCopyWithViewPass(),
630632
config.sym_shape_eval_pass,
631633
config.to_out_var_pass,

0 commit comments

Comments
 (0)