Repository navigation
grad property - #1293
Closed
yueyinqiu wants to merge 11 commits into
Closed
grad property#1293yueyinqiu wants to merge 11 commits into
yueyinqiu wants to merge 11 commits into
Conversation
Contributor
Author
|
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 = tI have no idea how to deal with that... Just keep it leaking? |
yueyinqiu
marked this pull request as ready for review
April 26, 2024 06:24
| return new Tensor(res); | ||
| } | ||
| set { | ||
| NativeMethods.THSTensor_set_grad(Handle, value?.Handle ?? IntPtr.Zero); |
Contributor
There was a problem hiding this comment.
Why did you remove the detach from dispose scope?
You also removed the MoveToOtherDisposeScope which was listed above in the to function.
Contributor
Author
There was a problem hiding this comment.
It seems that I have misunderstood something... I have reverted them.
Contributor
Author
There was a problem hiding this comment.
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?
yueyinqiu
marked this pull request as draft
April 26, 2024 14:36
yueyinqiu
marked this pull request as ready for review
April 26, 2024 14:48
yueyinqiu
marked this pull request as draft
April 26, 2024 14:50
Contributor
Author
|
Perhaps I shall create a new pull request for this... |
Contributor
Author
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

close #1291