File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Expand file tree Collapse file tree 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
3737 /// <summary>
3838 /// <see cref="ITransformer" /> for the <see cref="DnnRetrainEstimator"/>.
3939 /// </summary>
40- internal sealed class DnnRetrainTransformer : RowToRowTransformerBase
40+ internal sealed class DnnRetrainTransformer : RowToRowTransformerBase , IDisposable
4141 {
42+ private bool _isDisposed ;
43+
4244 private readonly IHostEnvironment _env ;
4345 private readonly string _modelLocation ;
4446 private readonly bool _isTemporarySavedModel ;
@@ -723,13 +725,11 @@ private protected override void SaveModel(ModelSaveContext ctx)
723725 } ) ;
724726 }
725727
726- ~ DnnRetrainTransformer ( )
728+ public void Dispose ( )
727729 {
728- Dispose ( false ) ;
729- }
730+ if ( _isDisposed )
731+ return ;
730732
731- private void Dispose ( bool disposing )
732- {
733733 // Ensure that the Session is not null and it's handle is not Zero, as it may have already been disposed/finalized.
734734 // Technically we shouldn't be calling this if disposing == false, since we're running in finalizer
735735 // 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)
747747 {
748748 DeleteFolderWithRetries ( Host , _modelLocation ) ;
749749 }
750+
751+ _isDisposed = true ;
750752 }
751753 }
752754
You can’t perform that action at this time.
0 commit comments