Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbkoch committed Jan 25, 2025
1 parent e73153f commit cc3b1f8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 73 deletions.
1 change: 0 additions & 1 deletion shared/libebm/CalcInteractionStrength.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ extern double PartitionMultiDimensionalFull(InteractionCore* const pInteractionC
BinBase* aAuxiliaryBinsBase,
BinBase* const aBinsBase);


// there is a race condition for decrementing this variable, but if a thread loses the
// race then it just doesn't get decremented as quickly, which we can live with
static int g_cLogCalcInteractionStrength = 10;
Expand Down
90 changes: 18 additions & 72 deletions shared/libebm/PartitionMultiDimensionalFull.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ template<bool bHessian, size_t cCompilerScores> class PartitionMultiDimensionalF
const FloatCalc regLambda,
const FloatCalc deltaStepMax,
BinBase* const aAuxiliaryBinsBase,
BinBase* const aBinsBase
) {
BinBase* const aBinsBase) {
auto* const aAuxiliaryBins =
aAuxiliaryBinsBase
->Specialize<FloatMain, UIntMain, true, true, bHessian, GetArrayScores(cCompilerScores)>();
Expand All @@ -46,7 +45,6 @@ template<bool bHessian, size_t cCompilerScores> class PartitionMultiDimensionalF
const size_t cScores = GET_COUNT_SCORES(cCompilerScores, pInteractionCore->GetCountScores());
const size_t cBytesPerBin = GetBinSize<FloatMain, UIntMain>(true, true, bHessian, cScores);


Bin<FloatMain, UIntMain, true, true, bHessian, GetArrayScores(cCompilerScores)> totalBin;
static constexpr bool bUseStackMemory = k_dynamicScores != cCompilerScores;
auto* const aTotalGradPair = bUseStackMemory ? totalBin.GetGradientPairs() : aAuxiliaryBins->GetGradientPairs();
Expand Down Expand Up @@ -103,28 +101,13 @@ template<bool bHessian, size_t cPossibleScores> class PartitionMultiDimensionalF
const FloatCalc regLambda,
const FloatCalc deltaStepMax,
BinBase* aAuxiliaryBinsBase,
BinBase* const aBinsBase
) {
BinBase* const aBinsBase) {
if(cPossibleScores == pInteractionCore->GetCountScores()) {
return PartitionMultiDimensionalFullInternal<bHessian, cPossibleScores>::Func(pInteractionCore,
cTensorBins,
flags,
regAlpha,
regLambda,
deltaStepMax,
aAuxiliaryBinsBase,
aBinsBase
);
return PartitionMultiDimensionalFullInternal<bHessian, cPossibleScores>::Func(
pInteractionCore, cTensorBins, flags, regAlpha, regLambda, deltaStepMax, aAuxiliaryBinsBase, aBinsBase);
} else {
return PartitionMultiDimensionalFullTarget<bHessian, cPossibleScores + 1>::Func(pInteractionCore,
cTensorBins,
flags,
regAlpha,
regLambda,
deltaStepMax,
aAuxiliaryBinsBase,
aBinsBase
);
return PartitionMultiDimensionalFullTarget<bHessian, cPossibleScores + 1>::Func(
pInteractionCore, cTensorBins, flags, regAlpha, regLambda, deltaStepMax, aAuxiliaryBinsBase, aBinsBase);
}
}
};
Expand All @@ -140,17 +123,9 @@ template<bool bHessian> class PartitionMultiDimensionalFullTarget<bHessian, k_cC
const FloatCalc regLambda,
const FloatCalc deltaStepMax,
BinBase* aAuxiliaryBinsBase,
BinBase* const aBinsBase
) {
return PartitionMultiDimensionalFullInternal<bHessian, k_dynamicScores>::Func(pInteractionCore,
cTensorBins,
flags,
regAlpha,
regLambda,
deltaStepMax,
aAuxiliaryBinsBase,
aBinsBase
);
BinBase* const aBinsBase) {
return PartitionMultiDimensionalFullInternal<bHessian, k_dynamicScores>::Func(
pInteractionCore, cTensorBins, flags, regAlpha, regLambda, deltaStepMax, aAuxiliaryBinsBase, aBinsBase);
}
};

Expand All @@ -161,56 +136,27 @@ extern double PartitionMultiDimensionalFull(InteractionCore* const pInteractionC
const FloatCalc regLambda,
const FloatCalc deltaStepMax,
BinBase* aAuxiliaryBinsBase,
BinBase* const aBinsBase
) {
BinBase* const aBinsBase) {
const size_t cRuntimeScores = pInteractionCore->GetCountScores();

EBM_ASSERT(1 <= cRuntimeScores);
if(pInteractionCore->IsHessian()) {
if(size_t{1} != cRuntimeScores) {
// muticlass
return PartitionMultiDimensionalFullTarget<true, k_cCompilerScoresStart>::Func(pInteractionCore,
cTensorBins,
flags,
regAlpha,
regLambda,
deltaStepMax,
aAuxiliaryBinsBase,
aBinsBase
);
return PartitionMultiDimensionalFullTarget<true, k_cCompilerScoresStart>::Func(
pInteractionCore, cTensorBins, flags, regAlpha, regLambda, deltaStepMax, aAuxiliaryBinsBase, aBinsBase);
} else {
return PartitionMultiDimensionalFullInternal<true, k_oneScore>::Func(pInteractionCore,
cTensorBins,
flags,
regAlpha,
regLambda,
deltaStepMax,
aAuxiliaryBinsBase,
aBinsBase
);
return PartitionMultiDimensionalFullInternal<true, k_oneScore>::Func(
pInteractionCore, cTensorBins, flags, regAlpha, regLambda, deltaStepMax, aAuxiliaryBinsBase, aBinsBase);
}
} else {
if(size_t{1} != cRuntimeScores) {
// Odd: gradient multiclass. Allow it, but do not optimize for it
return PartitionMultiDimensionalFullInternal<false, k_dynamicScores>::Func(pInteractionCore,
cTensorBins,
flags,
regAlpha,
regLambda,
deltaStepMax,
aAuxiliaryBinsBase,
aBinsBase
);
return PartitionMultiDimensionalFullInternal<false, k_dynamicScores>::Func(
pInteractionCore, cTensorBins, flags, regAlpha, regLambda, deltaStepMax, aAuxiliaryBinsBase, aBinsBase);
} else {
return PartitionMultiDimensionalFullInternal<false, k_oneScore>::Func(pInteractionCore,
cTensorBins,
flags,
regAlpha,
regLambda,
deltaStepMax,
aAuxiliaryBinsBase,
aBinsBase
);
return PartitionMultiDimensionalFullInternal<false, k_oneScore>::Func(
pInteractionCore, cTensorBins, flags, regAlpha, regLambda, deltaStepMax, aAuxiliaryBinsBase, aBinsBase);
}
}
}
Expand Down

0 comments on commit cc3b1f8

Please sign in to comment.