Commit 8bee6d6
Return unsafe_view instead of view from matmul when folding occurs
When tensor folding occurs during matmul operation returned tensor is a view.
This can cause issues when matmul is used inside a custom function
and such view is then returned as output. Then it cannot be modified inplace
and causes errors.
It can be especially problematic when after such function inplace allreduce
is performed.
Issue is resolved when unsafe_view is returned from matmul instead.
This solution aligns matmul decomposition with eager implementation
in such a way that a non view tensor is returned.
Pull request openned to pytorch pytorch#134568
Change-Id: I77484ff6f22d3e290352348b1acbffa267eb063b1 parent d9ba83d commit 8bee6d6
File tree
2 files changed
+61
-2
lines changed- test/custom_function
- torch/_decomp
2 files changed
+61
-2
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 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4361 | 4361 | | |
4362 | 4362 | | |
4363 | 4363 | | |
4364 | | - | |
| 4364 | + | |
4365 | 4365 | | |
4366 | 4366 | | |
4367 | | - | |
| 4367 | + | |
4368 | 4368 | | |
4369 | 4369 | | |
4370 | 4370 | | |
| |||
0 commit comments