Commit f99e9e8
Fix retain_grad() documentation for leaf vs non-leaf tensors (#3657)
The documentation incorrectly stated that calling retain_grad() on a
non-leaf node results in a no-op. This is misleading because:
- retain_grad() on a non-leaf tensor with requires_grad=True correctly
retains gradients (not a no-op)
- retain_grad() on a leaf tensor is a no-op (already retains by default)
- retain_grad() on a tensor with requires_grad=False throws an error
Updated the documentation and summary table to accurately reflect this
behavior.
Fixes #3652
## Description
<!--- Describe your changes in detail -->
## Checklist
<!--- Make sure to add `x` to all items in the following checklist: -->
- [ ] The issue that is being fixed is referred in the description (see
above "Fixes #ISSUE_NUMBER")
- [ ] Only one issue is addressed in this pull request
- [ ] Labels from the issue that this PR is fixing are added to this
pull request
- [ ] No unnecessary issues are included into this pull request.
cc @jbschlosser
Co-authored-by: Svetlana Karslioglu <[email protected]>
Co-authored-by: sekyondaMeta <[email protected]>1 parent bc79723 commit f99e9e8
1 file changed
+7
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
265 | 265 | | |
266 | 266 | | |
267 | 267 | | |
268 | | - | |
269 | | - | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
270 | 272 | | |
271 | 273 | | |
272 | 274 | | |
| |||
298 | 300 | | |
299 | 301 | | |
300 | 302 | | |
301 | | - | |
| 303 | + | |
302 | 304 | | |
303 | | - | |
| 305 | + | |
304 | 306 | | |
305 | 307 | | |
306 | 308 | | |
307 | | - | |
| 309 | + | |
308 | 310 | | |
309 | 311 | | |
310 | 312 | | |
| |||
0 commit comments