Commit f729aff
authored
[Bug Fix] Fix view grad when out_grad is not contiguous (PaddlePaddle#76679)
* Fix view grad when out_grad is not contiguous
* feat(phi): add no_need_buffer for view_shape_grad in backward.yaml
Add `no_need_buffer: input` to the view_shape_grad backward operator configuration. This indicates that the gradient computation for view_shape does not require the input tensor buffer, optimizing memory usage during backward passes.
* feat(test): add gradient test for view and transpose operations
Add a new test case `TestViewGrad.test_dygraph` to verify gradient correctness when using `view` followed by `transpose` in dynamic graph mode. The test ensures that the computed gradients match expected values, improving coverage for tensor manipulation operations.1 parent b6ebea4 commit f729aff
File tree
3 files changed
+46
-2
lines changed- paddle/phi
- kernels/stride
- ops/yaml
- test/legacy_test
3 files changed
+46
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
18 | 20 | | |
19 | 21 | | |
20 | 22 | | |
| |||
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
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 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
37 | 65 | | |
38 | 66 | | |
39 | 67 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4044 | 4044 | | |
4045 | 4045 | | |
4046 | 4046 | | |
| 4047 | + | |
4047 | 4048 | | |
4048 | 4049 | | |
4049 | 4050 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1092 | 1092 | | |
1093 | 1093 | | |
1094 | 1094 | | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
1095 | 1110 | | |
1096 | 1111 | | |
0 commit comments