Skip to content

Commit

Permalink
revert using int64_t in findBestSplit* functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ahuber21 committed Mar 20, 2023
1 parent 4573fa5 commit fb5556f
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,26 +117,26 @@ public:
bool terminateCriteria(ImpurityData & imp, algorithmFPType impurityThreshold, size_t nSamples) const { return imp.value() < impurityThreshold; }

template <typename BinIndexType>
int64_t findBestSplitForFeatureSorted(algorithmFPType * featureBuf, IndexType iFeature, const IndexType * aIdx, size_t n, size_t nMinSplitPart,
const ImpurityData & curImpurity, TSplitData & split, const algorithmFPType minWeightLeaf,
const algorithmFPType totalWeights, const BinIndexType * binIndex) const;
int findBestSplitForFeatureSorted(algorithmFPType * featureBuf, IndexType iFeature, const IndexType * aIdx, size_t n, size_t nMinSplitPart,
const ImpurityData & curImpurity, TSplitData & split, const algorithmFPType minWeightLeaf,
const algorithmFPType totalWeights, const BinIndexType * binIndex) const;
template <typename BinIndexType>
void computeHistFewClassesWithoutWeights(IndexType iFeature, const IndexType * aIdx, const BinIndexType * binIndex, size_t n) const;
template <typename BinIndexType>
void computeHistFewClassesWithWeights(IndexType iFeature, const IndexType * aIdx, const BinIndexType * binIndex, size_t n) const;
template <typename BinIndexType>
void computeHistManyClasses(IndexType iFeature, const IndexType * aIdx, const BinIndexType * binIndex, size_t n) const;

int64_t findBestSplitbyHistDefault(int nDiffFeatMax, size_t n, size_t nMinSplitPart, const ImpurityData & curImpurity, TSplitData & split,
const algorithmFPType minWeightLeaf, const algorithmFPType totalWeights) const;
int findBestSplitbyHistDefault(int nDiffFeatMax, size_t n, size_t nMinSplitPart, const ImpurityData & curImpurity, TSplitData & split,
const algorithmFPType minWeightLeaf, const algorithmFPType totalWeights) const;

template <int K, bool noWeights>
int64_t findBestSplitFewClasses(int nDiffFeatMax, size_t n, size_t nMinSplitPart, const ImpurityData & curImpurity, TSplitData & split,
const algorithmFPType minWeightLeaf, const algorithmFPType totalWeights) const;
int findBestSplitFewClasses(int nDiffFeatMax, size_t n, size_t nMinSplitPart, const ImpurityData & curImpurity, TSplitData & split,
const algorithmFPType minWeightLeaf, const algorithmFPType totalWeights) const;

template <bool noWeights>
int64_t findBestSplitFewClassesDispatch(int nDiffFeatMax, size_t n, size_t nMinSplitPart, const ImpurityData & curImpurity, TSplitData & split,
const algorithmFPType minWeightLeaf, const algorithmFPType totalWeights) const;
int findBestSplitFewClassesDispatch(int nDiffFeatMax, size_t n, size_t nMinSplitPart, const ImpurityData & curImpurity, TSplitData & split,
const algorithmFPType minWeightLeaf, const algorithmFPType totalWeights) const;

template <bool noWeights, typename BinIndexType>
void finalizeBestSplit(const IndexType * aIdx, const BinIndexType * binIndex, size_t n, IndexType iFeature, size_t idxFeatureValueBestSplit,
Expand Down Expand Up @@ -613,10 +613,10 @@ void UnorderedRespHelper<algorithmFPType, cpu>::computeHistManyClasses(IndexType
}

template <typename algorithmFPType, CpuType cpu>
int64_t UnorderedRespHelper<algorithmFPType, cpu>::findBestSplitbyHistDefault(int nDiffFeatMax, size_t n, size_t nMinSplitPart,
const ImpurityData & curImpurity, TSplitData & split,
const algorithmFPType minWeightLeaf,
const algorithmFPType totalWeights) const
int UnorderedRespHelper<algorithmFPType, cpu>::findBestSplitbyHistDefault(int nDiffFeatMax, size_t n, size_t nMinSplitPart,
const ImpurityData & curImpurity, TSplitData & split,
const algorithmFPType minWeightLeaf,
const algorithmFPType totalWeights) const
{
auto nFeatIdx = _idxFeatureBuf.get();
auto featWeights = _weightsFeatureBuf.get();
Expand Down Expand Up @@ -692,10 +692,9 @@ int64_t UnorderedRespHelper<algorithmFPType, cpu>::findBestSplitbyHistDefault(in

template <typename algorithmFPType, CpuType cpu>
template <int K, bool noWeights>
int64_t UnorderedRespHelper<algorithmFPType, cpu>::findBestSplitFewClasses(int nDiffFeatMax, size_t n, size_t nMinSplitPart,
const ImpurityData & curImpurity, TSplitData & split,
const algorithmFPType minWeightLeaf,
const algorithmFPType totalWeights) const
int UnorderedRespHelper<algorithmFPType, cpu>::findBestSplitFewClasses(int nDiffFeatMax, size_t n, size_t nMinSplitPart,
const ImpurityData & curImpurity, TSplitData & split,
const algorithmFPType minWeightLeaf, const algorithmFPType totalWeights) const
{
auto nSamplesPerClass = _samplesPerClassBuf.get();
auto nFeatIdx = _idxFeatureBuf.get();
Expand Down Expand Up @@ -790,10 +789,10 @@ int64_t UnorderedRespHelper<algorithmFPType, cpu>::findBestSplitFewClasses(int n

template <typename algorithmFPType, CpuType cpu>
template <bool noWeights>
int64_t UnorderedRespHelper<algorithmFPType, cpu>::findBestSplitFewClassesDispatch(int nDiffFeatMax, size_t n, size_t nMinSplitPart,
const ImpurityData & curImpurity, TSplitData & split,
const algorithmFPType minWeightLeaf,
const algorithmFPType totalWeights) const
int UnorderedRespHelper<algorithmFPType, cpu>::findBestSplitFewClassesDispatch(int nDiffFeatMax, size_t n, size_t nMinSplitPart,
const ImpurityData & curImpurity, TSplitData & split,
const algorithmFPType minWeightLeaf,
const algorithmFPType totalWeights) const
{
DAAL_ASSERT(_nClasses <= _nClassesThreshold);
switch (_nClasses)
Expand All @@ -811,9 +810,10 @@ int64_t UnorderedRespHelper<algorithmFPType, cpu>::findBestSplitFewClassesDispat

template <typename algorithmFPType, CpuType cpu>
template <typename BinIndexType>
int64_t UnorderedRespHelper<algorithmFPType, cpu>::findBestSplitForFeatureSorted(
algorithmFPType * featureBuf, IndexType iFeature, const IndexType * aIdx, size_t n, size_t nMinSplitPart, const ImpurityData & curImpurity,
TSplitData & split, const algorithmFPType minWeightLeaf, const algorithmFPType totalWeights, const BinIndexType * binIndex) const
int UnorderedRespHelper<algorithmFPType, cpu>::findBestSplitForFeatureSorted(algorithmFPType * featureBuf, IndexType iFeature, const IndexType * aIdx,
size_t n, size_t nMinSplitPart, const ImpurityData & curImpurity,
TSplitData & split, const algorithmFPType minWeightLeaf,
const algorithmFPType totalWeights, const BinIndexType * binIndex) const
{
const auto nDiffFeatMax = this->indexedFeatures().numIndices(iFeature);
_samplesPerClassBuf.setValues(nClasses() * nDiffFeatMax, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ public:
const algorithmFPType accuracy, const ImpurityData & curImpurity, TSplitData & split,
const algorithmFPType minWeightLeaf, const algorithmFPType totalWeights) const;
template <typename BinIndexType>
int64_t findBestSplitForFeatureSorted(algorithmFPType * featureBuf, IndexType iFeature, const IndexType * aIdx, size_t n, size_t nMinSplitPart,
const ImpurityData & curImpurity, TSplitData & split, const algorithmFPType minWeightLeaf,
const algorithmFPType totalWeights, const BinIndexType * binIndex) const;
int findBestSplitForFeatureSorted(algorithmFPType * featureBuf, IndexType iFeature, const IndexType * aIdx, size_t n, size_t nMinSplitPart,
const ImpurityData & curImpurity, TSplitData & split, const algorithmFPType minWeightLeaf,
const algorithmFPType totalWeights, const BinIndexType * binIndex) const;

typedef double intermSummFPType;
template <typename BinIndexType>
Expand All @@ -126,9 +126,9 @@ public:
intermSummFPType & sumTotal) const;

template <bool noWeights, bool featureUnordered>
int64_t findBestSplitByHist(size_t nDiffFeatMax, intermSummFPType sumTotal, algorithmFPType * buf, size_t n, size_t nMinSplitPart,
const ImpurityData & curImpurity, TSplitData & split, const algorithmFPType minWeightLeaf,
const algorithmFPType totalWeights) const;
int findBestSplitByHist(size_t nDiffFeatMax, intermSummFPType sumTotal, algorithmFPType * buf, size_t n, size_t nMinSplitPart,
const ImpurityData & curImpurity, TSplitData & split, const algorithmFPType minWeightLeaf,
const algorithmFPType totalWeights) const;

template <bool noWeights, typename BinIndexType>
void finalizeBestSplit(const IndexType * aIdx, const BinIndexType * binIndex, size_t n, IndexType iFeature, size_t idxFeatureValueBestSplit,
Expand Down Expand Up @@ -488,9 +488,9 @@ void OrderedRespHelper<algorithmFPType, cpu>::computeHistWithWeights(algorithmFP
template <typename algorithmFPType, CpuType cpu>

template <bool noWeights, bool featureUnordered>
int64_t OrderedRespHelper<algorithmFPType, cpu>::findBestSplitByHist(size_t nDiffFeatMax, intermSummFPType sumTotal, algorithmFPType * buf, size_t n,
size_t nMinSplitPart, const ImpurityData & curImpurity, TSplitData & split,
const algorithmFPType minWeightLeaf, const algorithmFPType totalWeights) const
int OrderedRespHelper<algorithmFPType, cpu>::findBestSplitByHist(size_t nDiffFeatMax, intermSummFPType sumTotal, algorithmFPType * buf, size_t n,
size_t nMinSplitPart, const ImpurityData & curImpurity, TSplitData & split,
const algorithmFPType minWeightLeaf, const algorithmFPType totalWeights) const
{
auto featWeights = _weightsFeatureBuf.get();
auto nFeatIdx = _idxFeatureBuf.get(); //number of indexed feature values, array
Expand Down Expand Up @@ -537,11 +537,10 @@ int64_t OrderedRespHelper<algorithmFPType, cpu>::findBestSplitByHist(size_t nDif

template <typename algorithmFPType, CpuType cpu>
template <typename BinIndexType>
int64_t OrderedRespHelper<algorithmFPType, cpu>::findBestSplitForFeatureSorted(algorithmFPType * buf, IndexType iFeature, const IndexType * aIdx,
size_t n, size_t nMinSplitPart, const ImpurityData & curImpurity,
TSplitData & split, const algorithmFPType minWeightLeaf,
const algorithmFPType totalWeights,
const BinIndexType * binIndex) const
int OrderedRespHelper<algorithmFPType, cpu>::findBestSplitForFeatureSorted(algorithmFPType * buf, IndexType iFeature, const IndexType * aIdx,
size_t n, size_t nMinSplitPart, const ImpurityData & curImpurity,
TSplitData & split, const algorithmFPType minWeightLeaf,
const algorithmFPType totalWeights, const BinIndexType * binIndex) const
{
const auto nDiffFeatMax = this->indexedFeatures().numIndices(iFeature);
_idxFeatureBuf.setValues(nDiffFeatMax, 0);
Expand Down

0 comments on commit fb5556f

Please sign in to comment.