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 14
14
from torch .fx .passes .infra .pass_base import PassBase , PassResult
15
15
16
16
17
- def _is_view_copy (node : torch .fx .Node ) -> bool :
17
+ def _is_view_copy (node : torch .fx .Node ) -> bool : # pyre-ignore[11]
18
18
return node .op == "call_function" and node .target in (
19
19
torch .ops .aten .view_copy .default ,
20
20
ops .edge .aten .view_copy .default ,
21
21
)
22
22
23
23
24
- class NormalizeViewCopyBasePass (PassBase ):
24
+ class NormalizeViewCopyBasePass (PassBase ): # pyre-ignore[11]
25
25
"""
26
26
Point each view_copy to the first upstream non-view.
27
27
28
28
After this pass, the base of each view_copy is not a view_copy.
29
29
30
30
When combined with dead-code elimination, this pass removes redundant
31
31
view_copy nodes.
32
-
33
- TODO: replace RemoveRedundantViewCopyPass with NormalizeViewCopyBasePass + dead code elimination.
34
32
"""
35
33
36
- def call (self , graph_module : torch .fx .GraphModule ) -> PassResult :
34
+ def call (self , graph_module : torch .fx .GraphModule ) -> PassResult : # pyre-ignore[11]
37
35
n_updated = 0
38
36
for module in graph_module .modules ():
39
37
if not isinstance (module , torch .fx .GraphModule ):
Original file line number Diff line number Diff line change 24
24
from executorch .exir .passes import (
25
25
base_post_op_replace_passes ,
26
26
base_pre_op_replace_passes ,
27
+ dead_code_elimination_pass ,
27
28
EdgeToBackendOpsPass ,
28
29
MemoryFormatOpsPass ,
29
30
OpReplacePass ,
@@ -626,6 +627,7 @@ def pre_memory_planning_passes(config: ExecutorchBackendConfig) -> List[PassType
626
627
# pyre-ignore
627
628
return [
628
629
NormalizeViewCopyBasePass (),
630
+ dead_code_elimination_pass ,
629
631
ReplaceViewCopyWithViewPass (),
630
632
config .sym_shape_eval_pass ,
631
633
config .to_out_var_pass ,
You can’t perform that action at this time.
0 commit comments