@@ -39,7 +39,7 @@ public void DisposablesValidityWhenNotSorted()
39
39
var sequences = CreateTestSequences ( ) ;
40
40
using var scope = torch . NewDisposeScope ( ) ;
41
41
var packed = torch . nn . utils . rnn . pack_sequence ( sequences , enforce_sorted : false ) ;
42
- Assert . Equal ( 5 , scope . DisposablesCount ) ;
42
+ Assert . Equal ( 1 , scope . DisposablesCount ) ;
43
43
AssertPackedSequenceValid ( packed ) ;
44
44
}
45
45
@@ -49,7 +49,7 @@ public void DisposablesValidityWhenSorted()
49
49
var sequences = CreateTestSequences ( ) ;
50
50
using var scope = torch . NewDisposeScope ( ) ;
51
51
var packed = torch . nn . utils . rnn . pack_sequence ( sequences , enforce_sorted : true ) ;
52
- Assert . Equal ( 5 , scope . DisposablesCount ) ;
52
+ Assert . Equal ( 1 , scope . DisposablesCount ) ;
53
53
Assert . False ( GetPackedSequenceIsInvalid ( packed ) ) ;
54
54
Assert . False ( packed . batch_sizes . IsInvalid ) ;
55
55
Assert . False ( packed . data . IsInvalid ) ;
@@ -70,17 +70,17 @@ public void DisposeScopeStatistics()
70
70
AssertStatCounts ( 0 , 7 , 0 , 0 , 0 ) ;
71
71
72
72
var inScope = torch . nn . utils . rnn . pack_sequence ( sequences , enforce_sorted : true ) ;
73
- AssertStatCounts ( 5 , 7 , 0 , 0 , 5 ) ;
73
+ AssertStatCounts ( 5 , 7 , 4 , 0 , 1 ) ;
74
74
75
75
scope . Attach ( outOfScope ) ;
76
- //Possible subtle bug. When attaching an object that isn't owned by any scope, the count goes negative .
77
- AssertStatCounts ( 5 , 7 , - 1 , 0 , 6 ) ;
76
+ //Possible subtle bug. When attaching an object that isn't owned by any scope, the count subtracts .
77
+ AssertStatCounts ( 5 , 7 , 3 , 0 , 2 ) ;
78
78
79
79
scope . Detach ( inScope ) ;
80
- AssertStatCounts ( 5 , 7 , 0 , 0 , 5 ) ;
80
+ AssertStatCounts ( 5 , 7 , 4 , 0 , 1 ) ;
81
81
82
82
outOfScope . Dispose ( ) ;
83
- AssertStatCounts ( 5 , 7 , 0 , 5 , 0 ) ;
83
+ AssertStatCounts ( 5 , 7 , 4 , 5 , - 4 ) ;
84
84
85
85
}
86
86
0 commit comments