Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check for requires_grad in pre_forward
Previously, when checking whether the gradient was required to determine whether to apply hooks, only the existance of a grad_fn of the input was checked. This was insufficient, since the first layer input may not have a grad_fn yet, but still require a gradient. Now, the input is checked for requires_grad instead, since a grad_fn is not needed, because of the subsequent `Identity.apply`. It is still sufficient to check for grad_fn for the output, since the output will always have a grad_fn if a gradient is required.
- Loading branch information