-
Notifications
You must be signed in to change notification settings - Fork 212
grad property #1293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
grad property #1293
Conversation
By the way how about the circular reference? using TorchSharp;
for (; ; )
{
var t = torch.zeros(1000);
t.grad = t;
// t.set_grad(t);
} PyTorch does not allow that: However if the trick is played on two tensors, it's ok: import torch
t = torch.zeros(1000)
g = torch.zeros(1000)
t.grad = g
g.grad = t I have no idea how to deal with that... Just keep it leaking? |
return new Tensor(res); | ||
} | ||
set { | ||
NativeMethods.THSTensor_set_grad(Handle, value?.Handle ?? IntPtr.Zero); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you remove the detach from dispose scope?
You also removed the MoveToOtherDisposeScope which was listed above in the to
function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that I have misunderstood something... I have reverted them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have reviewed it again and I'm now more confident about the removal. Could you please check my comment here and the new commit about this?
Perhaps I shall create a new pull request for this... |
close #1291