22// The .NET Foundation licenses this file to you under the MIT license.
33// See the LICENSE file in the project root for more information.
44
5+ using System ;
56using System . Linq ;
67using Microsoft . ML . Internal . Utilities ;
78using Microsoft . ML . Runtime ;
@@ -99,7 +100,7 @@ public EstimatorChain<TNewTrans> Append<TNewTrans>(IEstimator<TNewTrans> estimat
99100 /// cached data. It is helpful to have a caching checkpoint before trainers or feature engineering that take multiple data passes.
100101 /// It is also helpful to have after a slow operation, for example after dataset loading from a slow source or after feature
101102 /// engineering that is slow on its apply phase, if downstream estimators will do multiple passes over the output of this operation.
102- /// Adding a cache checkpoint at the end of an <see cref="EstimatorChain{TLastTransformer}"/> is meaningless and should be avoided.
103+ /// Adding a cache checkpoint at the begin or end of an <see cref="EstimatorChain{TLastTransformer}"/> is meaningless and should be avoided.
103104 /// Cache checkpoints should be removed if disk thrashing or OutOfMemory exceptions are seen, which can occur on when the featured
104105 /// dataset immediately prior to the checkpoint is larger than available RAM.
105106 /// </summary>
@@ -108,9 +109,12 @@ public EstimatorChain<TLastTransformer> AppendCacheCheckpoint(IHostEnvironment e
108109 {
109110 Contracts . CheckValue ( env , nameof ( env ) ) ;
110111
111- if ( _estimators . Length == 0 || _needCacheAfter . Last ( ) )
112+ if ( _estimators . Length == 0 )
113+ throw new InvalidOperationException ( "Current estimator chain has no estimator, can't append cache checkpoint." ) ;
114+
115+ if ( _needCacheAfter . Last ( ) )
112116 {
113- // If there are no estimators, or if we already need to cache after this, we don't need to do anything else.
117+ // If we already need to cache after this, we don't need to do anything else.
114118 return this ;
115119 }
116120
0 commit comments