public void TensorsThatShouldNotBeDisposedArent() { torch.Tensor data = torch.rand(10, 10); torch.Tensor undisposed = null; using (var d = torch.NewDisposeScope()) { undisposed = d.MoveToOuter(data * data + data); Assert.False(undisposed.IsInvalid); } // One was kept Assert.False(undisposed.IsInvalid); }
public void TensorsCanBeDisposedInTheMiddleOfTheProcess() { torch.Tensor data = torch.rand(10, 10); torch.Tensor t1, t2; using (var d = torch.NewDisposeScope()) { t1 = data * data + data; t2 = data + data - t1; t2 = d.DisposeEverythingBut(t2); Assert.True(t1.IsInvalid); t2 = t2 + data; } Assert.True(t2.IsInvalid); Assert.False(data.IsInvalid); }
public void DisposeScopesCanBeNestled() { DisposeScopeManager.Statistics.Reset(); torch.Tensor data = torch.rand(10, 10); using (torch.NewDisposeScope()) { var t1 = data * data + data; var innerCount = DisposeScopeManager.Statistics.ThreadTotalLiveCount; using (torch.NewDisposeScope()) { var t2 = data + data - t1; } // Inner scope was disposed Assert.Equal(DisposeScopeManager.Statistics.ThreadTotalLiveCount, innerCount); } // It was all disposed Assert.Equal(0, DisposeScopeManager.Statistics.ThreadTotalLiveCount); }
public void TensorsAreDisposedCorrectly() { torch.Tensor data = torch.rand(10, 10); var disposables = new List <torch.Tensor>(); using (var d = torch.NewDisposeScope()) { var newValue = data * data + data; disposables = d.DisposablesView.OfType <torch.Tensor>().ToList(); foreach (var disposable in disposables) { Assert.False(disposable.IsInvalid); } } // They were all disposed foreach (var disposable in disposables) { Assert.True(disposable.IsInvalid); } }
public override torch.Tensor forward(torch.Tensor t) { return(this.seq.forward(t)); }
public override torch.Tensor forward(torch.Tensor t) { return(torch.matmul(t, Weight)); }
public override torch.Tensor forward(torch.Tensor t) => bn1.forward(t);
public override torch.Tensor forward(torch.Tensor t) => t.clone();
public override torch.Tensor forward(torch.Tensor input) { throw new NotImplementedException(); }