add retain_grad method, to variable, so gradient gets stored during…#2078
add retain_grad method, to variable, so gradient gets stored during…#2078hughperkins wants to merge 2 commits intopytorch:masterfrom
retain_grad method, to variable, so gradient gets stored during…#2078Conversation
|
@apaszke is likely going to reject this PR :) |
… backpop, on non-user variables
|
(added unit test) |
|
(ah, our comments crossed en-route, or rather, I just wrote and pasted without noticing there were new comments :-) ) |
|
alright, fair enough. Can we keep this open until someone implement/proposes a better solution (no need to merge, but at least its a place-holder to remind us to find a better way to do something similar?) |
|
(or ... could we merge for now, and then replace the user API method, ie |
|
I'll chat with @apaszke today and discuss, we'll keep this open for now. |
|
@apaszke 's main reservations with this PR is that the PR in it's current state creates a reference cycle (which means higher memory usage until the GC kicks in). instead of holding onto self, you can create a weakref on self instead. |
|
Also, the method can insert the same hook multiple times, which is unnecessary |
|
closing in favor of #2199 |
|
Awesome, thanks! :-) |
…ddppq (pytorch#2078) * Fix cmake dependency error in static library case. Peer coded with @bddppq * Temporarily add back the private dependencies to the binary targets
… backpop, on non-user variables
Simplifies solving issues such as https://discuss.pytorch.org/t/problem-about-tensor-and-variable/4719