File tree 1 file changed +8
-6
lines changed 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -37,8 +37,10 @@ namespace Microsoft.ML.Transforms
37
37
/// <summary>
38
38
/// <see cref="ITransformer" /> for the <see cref="DnnRetrainEstimator"/>.
39
39
/// </summary>
40
- internal sealed class DnnRetrainTransformer : RowToRowTransformerBase
40
+ internal sealed class DnnRetrainTransformer : RowToRowTransformerBase , IDisposable
41
41
{
42
+ private bool _isDisposed ;
43
+
42
44
private readonly IHostEnvironment _env ;
43
45
private readonly string _modelLocation ;
44
46
private readonly bool _isTemporarySavedModel ;
@@ -723,13 +725,11 @@ private protected override void SaveModel(ModelSaveContext ctx)
723
725
} ) ;
724
726
}
725
727
726
- ~ DnnRetrainTransformer ( )
728
+ public void Dispose ( )
727
729
{
728
- Dispose ( false ) ;
729
- }
730
+ if ( _isDisposed )
731
+ return ;
730
732
731
- private void Dispose ( bool disposing )
732
- {
733
733
// Ensure that the Session is not null and it's handle is not Zero, as it may have already been disposed/finalized.
734
734
// Technically we shouldn't be calling this if disposing == false, since we're running in finalizer
735
735
// and the GC doesn't guarantee ordering of finalization of managed objects, but we have to make sure
@@ -747,6 +747,8 @@ private void Dispose(bool disposing)
747
747
{
748
748
DeleteFolderWithRetries ( Host , _modelLocation ) ;
749
749
}
750
+
751
+ _isDisposed = true ;
750
752
}
751
753
}
752
754
You can’t perform that action at this time.
0 commit comments