Skip to content
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

Attaching unowned tensor to a DisposeScope makes Statistics.DetachedFromScopeCount go negative. #1387

Closed
mvphelps opened this issue Oct 18, 2024 · 0 comments

Comments

@mvphelps
Copy link
Contributor

Repro:

[Fact]
    public void DetachedFromScopeCountNegative()
    {
        var stats = DisposeScopeManager.Statistics;
        stats.Reset();
        var t = torch.tensor(1);
        Assert.Equal(0, stats.DetachedFromScopeCount);
        var scope = torch.NewDisposeScope();
        scope.Attach(t);
        Assert.Equal(0, stats.DetachedFromScopeCount);
    }

Removing the branch in DisposeScope.Attach(IEnumerable<IDisposable> disposables) that subtracts fixes the issue and all tests pass, minus any tests checking counts (waiting on PR #1386 prior to fixing.

@mvphelps mvphelps changed the title Attaching unowner tensor to a DisposeScope makes Statistics.DetachedFromScopeCount go negative. Attaching unowned tensor to a DisposeScope makes Statistics.DetachedFromScopeCount go negative. Oct 18, 2024
mvphelps added a commit to mvphelps/TorchSharp that referenced this issue Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant