Commit e159e65
authored
Extend reinplace pass to select_copy.int (pytorch#15136)
This pull request refactors and centralizes the logic for replacing
"view_copy" operations with "view" operations in the graph
transformation passes for both the AOTInductor and CUDA backends. The
main change is the creation of a unified pass in
`backends/aoti/passes/replace_view_copy_with_view.py`, which replaces
the previous backend-specific implementations and expands support to
additional ops. The backend code is updated to use this new shared pass,
and redundant files are removed.
**Pass refactoring and centralization:**
* Created a new unified pass `replace_view_copy_with_view.py` in
`backends/aoti/passes` that replaces "view_copy" type ops (including
`slice_copy` and `select_copy`) with their corresponding "view" ops for
use in AOTInductor and CUDA backends.
[[1]](diffhunk://#diff-725a4a1f4634a11f716ae6f649894f6eea64edb21f56ad56cde92f18fdd2f713L7-R12)
[[2]](diffhunk://#diff-725a4a1f4634a11f716ae6f649894f6eea64edb21f56ad56cde92f18fdd2f713L18-R44)
[[3]](diffhunk://#diff-374a8b362bdad92dce92e7c3bb474dd6106fc80d7253e6b5d5a1c9fb971dc76eR1-R17)
* Removed the old backend-specific pass files
(`replace_slice_copy_with_slice.py`) from both `backends/apple/metal`
and `backends/cuda`.
[[1]](diffhunk://#diff-c4a228b182f50f778545991d472609ad705d2325994342174093ff374738851dL1-L118)
[[2]](diffhunk://#diff-f0e6cbb7940752204a85a43708b5424de89eb4556698043d6cc652c07eabd624L9-R15)
**Backend integration and API updates:**
* Updated both `metal_backend.py` and `cuda_backend.py` to import and
use the new `ReplaceViewCopyWithViewPass` instead of the previous
backend-specific implementations.
[[1]](diffhunk://#diff-20452c18c868bce8db75555905fdbc3a6347536697bdfea9b7187bd6c765a24eL15-R16)
[[2]](diffhunk://#diff-5b5ea2257772b3aba04b2534f5ea1429a0c631bfd25a7ef531f526e76c471d7aL15-R16)
* Modified the preprocessing step in both backends to apply the new
pass, which now handles both `slice_copy` and `select_copy` ops.
[[1]](diffhunk://#diff-20452c18c868bce8db75555905fdbc3a6347536697bdfea9b7187bd6c765a24eL96-R96)
[[2]](diffhunk://#diff-5b5ea2257772b3aba04b2534f5ea1429a0c631bfd25a7ef531f526e76c471d7aL126-R127)1 parent 312267e commit e159e65
File tree
6 files changed
+37
-138
lines changed- backends
- aoti/passes
- apple/metal
- cuda
6 files changed
+37
-138
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
Lines changed: 12 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
8 | 11 | | |
9 | | - | |
| 12 | + | |
10 | 13 | | |
11 | 14 | | |
12 | 15 | | |
| |||
15 | 18 | | |
16 | 19 | | |
17 | 20 | | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
| 21 | + | |
24 | 22 | | |
25 | 23 | | |
26 | 24 | | |
27 | 25 | | |
| 26 | + | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | | - | |
| 31 | + | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | | - | |
| 15 | + | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | | - | |
| 96 | + | |
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | 9 | | |
11 | 10 | | |
12 | 11 | | |
13 | 12 | | |
14 | 13 | | |
15 | 14 | | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | | - | |
| 15 | + | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
126 | | - | |
127 | | - | |
| 126 | + | |
| 127 | + | |
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
| |||
This file was deleted.
0 commit comments