File tree Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Original file line number Diff line number Diff line change 1414from 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 ):
Original file line number Diff line number Diff line change 2424from 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 ,
You can’t perform that action at this time.
0 commit comments