Skip to content

Commit

Permalink
fix crash in single feature tree boosting
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbkoch committed Dec 26, 2024
1 parent a8e1320 commit 50d4254
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions shared/libebm/PartitionOneDimensionalBoosting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ static ErrorEbm Flatten(BoosterShell* const pBoosterShell,
deltaStepMax);
}

EBM_ASSERT(pUpdateScore < aUpdateScore + cScores * cSlices);
*pUpdateScore = static_cast<FloatScore>(updateScore);
++pUpdateScore;

Expand Down Expand Up @@ -322,6 +323,20 @@ static ErrorEbm Flatten(BoosterShell* const pBoosterShell,
done:;
EBM_ASSERT(cSamplesTotalDebug == cSamplesExpectedDebug);

EBM_ASSERT(bNominal || pUpdateScore == aUpdateScore + cScores * cSlices);

EBM_ASSERT(bNominal || pSplit == cSlices - 1 + pInnerTermUpdate->GetSplitPointer(iDimension));

#ifndef NDEBUG
UIntSplit prevDebug = 0;
for(size_t iDebug = 0; iDebug < cSlices - 1; ++iDebug) {
UIntSplit curDebug = pInnerTermUpdate->GetSplitPointer(iDimension)[iDebug];
EBM_ASSERT(prevDebug < curDebug);
prevDebug = curDebug;
}
EBM_ASSERT(prevDebug < cBins);
#endif

EBM_ASSERT(nullptr == pMissingValueTreeNode || nullptr != pMissingBin);
if(nullptr != pMissingBin) {
EBM_ASSERT(bMissing);
Expand All @@ -347,18 +362,6 @@ static ErrorEbm Flatten(BoosterShell* const pBoosterShell,
} while(pGradientPairEnd != pGradientPair);
}

EBM_ASSERT(bNominal || pSplit == cSlices - 1 + pInnerTermUpdate->GetSplitPointer(iDimension));

#ifndef NDEBUG
UIntSplit prevDebug = 0;
for(size_t iDebug = 0; iDebug < cSlices - 1; ++iDebug) {
UIntSplit curDebug = pInnerTermUpdate->GetSplitPointer(iDimension)[iDebug];
EBM_ASSERT(prevDebug < curDebug);
prevDebug = curDebug;
}
EBM_ASSERT(prevDebug < cBins);
#endif

LOG_0(Trace_Verbose, "Exited Flatten");
return Error_None;
}
Expand All @@ -379,6 +382,7 @@ static ErrorEbm Flatten(BoosterShell* const pBoosterShell,
if(cBins == iEdge) {
// This cut would isolate the missing bin, but missing already has a cut.
// We still need to find the missing bin though in the tree, so continue.
bDone = true;
break;
}
}
Expand Down

0 comments on commit 50d4254

Please sign in to comment.