Skip to content

Commit 8087b37

Browse files
committed
fix: correct strategybuilder generics to match factory signature
Remove TNum generic parameter from StrategyBuilder and use outer class's T instead. This fixes the type mismatch where Build() was trying to pass Vector<IDistillationStrategy<Vector<TNum>, TNum>> to CreateStrategy which expects Vector<IDistillationStrategy<T, Vector<T>>>. Changes: - Change StrategyBuilder<TNum> to StrategyBuilder (non-generic) - Replace all TNum references with T from outer DistillationStrategyFactory<T> - Update Configure() return type from StrategyBuilder<T> to StrategyBuilder - Update all method return types from StrategyBuilder<TNum> to StrategyBuilder This resolves the compilation blocker at line 311. Resolves coderabbitai review comment on line 311.
1 parent 0b531ca commit 8087b37

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/KnowledgeDistillation/DistillationStrategyFactory.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -217,15 +217,15 @@ private static IDistillationStrategy<T, Vector<T>> CreateHybridStrategy(
217217
/// <summary>
218218
/// Creates a strategy with custom parameters using a fluent builder pattern.
219219
/// </summary>
220-
public static StrategyBuilder<T> Configure(DistillationStrategyType strategyType)
220+
public static StrategyBuilder Configure(DistillationStrategyType strategyType)
221221
{
222-
return new StrategyBuilder<T>(strategyType);
222+
return new StrategyBuilder(strategyType);
223223
}
224224

225225
/// <summary>
226226
/// Fluent builder for configuring distillation strategies with custom parameters.
227227
/// </summary>
228-
public class StrategyBuilder<TNum>
228+
public class StrategyBuilder
229229
{
230230
private readonly DistillationStrategyType _strategyType;
231231
private double _temperature = 3.0;
@@ -235,66 +235,66 @@ public class StrategyBuilder<TNum>
235235
private ContrastiveMode? _contrastiveMode;
236236
private Vector<string>? _featureLayerPairs;
237237
private Vector<string>? _attentionLayers;
238-
private Vector<IDistillationStrategy<Vector<TNum>, TNum>>? _strategies;
238+
private Vector<IDistillationStrategy<T, Vector<T>>>? _strategies;
239239
private Vector<double>? _strategyWeights;
240240

241241
internal StrategyBuilder(DistillationStrategyType strategyType)
242242
{
243243
_strategyType = strategyType;
244244
}
245245

246-
public StrategyBuilder<TNum> WithTemperature(double temperature)
246+
public StrategyBuilder WithTemperature(double temperature)
247247
{
248248
_temperature = temperature;
249249
return this;
250250
}
251251

252-
public StrategyBuilder<TNum> WithAlpha(double alpha)
252+
public StrategyBuilder WithAlpha(double alpha)
253253
{
254254
_alpha = alpha;
255255
return this;
256256
}
257257

258-
public StrategyBuilder<TNum> WithFeatureWeight(double weight)
258+
public StrategyBuilder WithFeatureWeight(double weight)
259259
{
260260
_featureWeight = weight;
261261
return this;
262262
}
263263

264-
public StrategyBuilder<TNum> WithAttentionWeight(double weight)
264+
public StrategyBuilder WithAttentionWeight(double weight)
265265
{
266266
_attentionWeight = weight;
267267
return this;
268268
}
269269

270-
public StrategyBuilder<TNum> WithContrastiveMode(ContrastiveMode mode)
270+
public StrategyBuilder WithContrastiveMode(ContrastiveMode mode)
271271
{
272272
_contrastiveMode = mode;
273273
return this;
274274
}
275275

276-
public StrategyBuilder<TNum> WithFeatureLayerPairs(Vector<string> layerPairs)
276+
public StrategyBuilder WithFeatureLayerPairs(Vector<string> layerPairs)
277277
{
278278
_featureLayerPairs = layerPairs;
279279
return this;
280280
}
281281

282-
public StrategyBuilder<TNum> WithAttentionLayers(Vector<string> layers)
282+
public StrategyBuilder WithAttentionLayers(Vector<string> layers)
283283
{
284284
_attentionLayers = layers;
285285
return this;
286286
}
287287

288-
public StrategyBuilder<TNum> WithStrategies(
289-
Vector<IDistillationStrategy<Vector<TNum>, TNum>> strategies,
288+
public StrategyBuilder WithStrategies(
289+
Vector<IDistillationStrategy<T, Vector<T>>> strategies,
290290
Vector<double>? weights = null)
291291
{
292292
_strategies = strategies;
293293
_strategyWeights = weights;
294294
return this;
295295
}
296296

297-
public IDistillationStrategy<Vector<TNum>, TNum> Build()
297+
public IDistillationStrategy<T, Vector<T>> Build()
298298
{
299299
return CreateStrategy(
300300
_strategyType,

0 commit comments

Comments
 (0)