Exemplo n.º 1
0
        public void DisposeScopeWorksForTestTraining1()
        {
            DisposeScopeManager.Statistics.Reset();
            using (var d = torch.NewDisposeScope()) {
                var testTraining = new TestTraining();
                testTraining.TestTraining1();
            }

            _testOutputHelper.WriteLine(
                $"Undisposed Tensors with DisposeScope: {DisposeScopeManager.Statistics.ThreadTotalLiveCount}");
            Assert.Equal(0, DisposeScopeManager.Statistics.ThreadTotalLiveCount);
        }
Exemplo n.º 2
0
        public void DisposeScopeWorksForTestTrainingConv2d()
        {
            DisposeScopeManager.Statistics.Reset();
            using (var d = torch.NewDisposeScope()) {
                var testTraining = new TestTraining();
                testTraining.TestTrainingConv2d();
                _testOutputHelper.WriteLine($"Undisposed Tensors inside DisposeScope: {d.DisposablesCount}");
            }

            Assert.Equal(0, DisposeScopeManager.Statistics.ThreadTotalLiveCount);
            _testOutputHelper.WriteLine(
                $"Undisposed Tensors after DisposeScope: {DisposeScopeManager.Statistics.ThreadTotalLiveCount}");
        }