Commit d07d25a
Fix MSELoss when target.requires_grad is True. (#44437)
Summary:
Pull Request resolved: #44437
MSELoss had a completely different (and incorrect, see #43228) path when target.requires_grad was True.
This PR does the following:
1) adds derivative support for target via the normal derivatives.yaml route
2) kill the different (and incorrect) path for when target.requires_grad was True
3) modify the MSELoss CriterionTests to verify that the target derivative is checked.
TODO:
1) do we still need check_criterion_jacobian when we run grad/gradgrad checks?
2) ensure the Module tests check when target.requires_grad
3) do we actually test when reduction='none' and reduction='mean'?
Test Plan: Imported from OSS
Reviewed By: albanD
Differential Revision: D23612166
Pulled By: gchanan
fbshipit-source-id: 4f74d38d8a81063c74e002e07fbb7837b2172a101 parent 9a3b83c commit d07d25a
File tree
4 files changed
+19
-35
lines changed- tools/autograd
- torch
- csrc/api/include/torch/nn/functional
- nn
- testing/_internal
4 files changed
+19
-35
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1205 | 1205 | | |
1206 | 1206 | | |
1207 | 1207 | | |
| 1208 | + | |
1208 | 1209 | | |
1209 | 1210 | | |
1210 | 1211 | | |
| |||
1551 | 1552 | | |
1552 | 1553 | | |
1553 | 1554 | | |
| 1555 | + | |
1554 | 1556 | | |
1555 | 1557 | | |
1556 | 1558 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
126 | 117 | | |
127 | 118 | | |
128 | 119 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2661 | 2661 | | |
2662 | 2662 | | |
2663 | 2663 | | |
2664 | | - | |
2665 | | - | |
2666 | | - | |
2667 | | - | |
2668 | | - | |
2669 | | - | |
2670 | | - | |
2671 | | - | |
2672 | | - | |
| 2664 | + | |
| 2665 | + | |
| 2666 | + | |
2673 | 2667 | | |
2674 | 2668 | | |
2675 | 2669 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3955 | 3955 | | |
3956 | 3956 | | |
3957 | 3957 | | |
3958 | | - | |
| 3958 | + | |
3959 | 3959 | | |
3960 | 3960 | | |
3961 | 3961 | | |
| |||
4302 | 4302 | | |
4303 | 4303 | | |
4304 | 4304 | | |
4305 | | - | |
| 4305 | + | |
4306 | 4306 | | |
4307 | 4307 | | |
4308 | 4308 | | |
| |||
5070 | 5070 | | |
5071 | 5071 | | |
5072 | 5072 | | |
5073 | | - | |
5074 | | - | |
5075 | 5073 | | |
5076 | 5074 | | |
5077 | 5075 | | |
| |||
5084 | 5082 | | |
5085 | 5083 | | |
5086 | 5084 | | |
5087 | | - | |
5088 | | - | |
5089 | | - | |
| 5085 | + | |
| 5086 | + | |
5090 | 5087 | | |
5091 | | - | |
5092 | | - | |
| 5088 | + | |
5093 | 5089 | | |
5094 | | - | |
| 5090 | + | |
| 5091 | + | |
5095 | 5092 | | |
5096 | 5093 | | |
5097 | 5094 | | |
| |||
0 commit comments