-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Closed
Labels
high prioritymodule: autogradRelated to torch.autograd, and the autograd engine in generalRelated to torch.autograd, and the autograd engine in generalmodule: docsRelated to our documentation, both in docs/ and docblocksRelated to our documentation, both in docs/ and docblockssmallWe think this is a small issue to fix. Consider knocking off high priority small issuesWe think this is a small issue to fix. Consider knocking off high priority small issuestriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module
Description
📚 Documentation
torch==1.5.0
The problem is the same for all three functions. For example, let's consider no_grad.
The documentation says: "This mode has no effect when using enable_grad context manager". This is not true:
import torch
x = torch.tensor([1.0], requires_grad=True)
with torch.enable_grad():
with torch.no_grad():
y = x * 2
assert not y.requires_gradAnd I mean that the documentation should be fixed, not the behavior of torch 😄
These functions just set grad enabled/disabled in __enter__ (or in the constructor in the case of set_grad_enabled) and set the previous state in __exit__. This is very intuitive. IMHO, it will be confusing if, for example, the behavior of no_grad changes depending on some other context.
Metadata
Metadata
Assignees
Labels
high prioritymodule: autogradRelated to torch.autograd, and the autograd engine in generalRelated to torch.autograd, and the autograd engine in generalmodule: docsRelated to our documentation, both in docs/ and docblocksRelated to our documentation, both in docs/ and docblockssmallWe think this is a small issue to fix. Consider knocking off high priority small issuesWe think this is a small issue to fix. Consider knocking off high priority small issuestriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module