MCPcopy Create free account
hub / github.com/catboost/catboost / TSplitHelper

Class TSplitHelper

catboost/cuda/gpu_data/oblivious_tree_bin_builder.cpp:9–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7 template <class TDataSet,
8 class TCtrSplitBuilder>
9 class TSplitHelper: public IBinarySplitProvider {
10 public:
11 TSplitHelper(TScopedCacheHolder& scopedCache,
12 TCtrSplitBuilder& builder,
13 const TBinarizedFeaturesManager& featuresManager,
14 const TDataSet& dataSet)
15 : ScopedCache(scopedCache)
16 , CtrSplitBuilder(builder)
17 , FeaturesManager(featuresManager)
18 , DataSet(dataSet)
19 {
20 }
21
22 const TMirrorBuffer<ui64>& GetCompressedBits(const TBinarySplit& split) const final {
23 const ui32 featureId = split.FeatureId;
24 if (DataSet.HasFeatures() && DataSet.GetFeatures().HasFeature(featureId)) {
25 return GetCompressedBitsFromGpuFeatures(DataSet.GetFeatures(), split, nullptr);
26 } else if (DataSet.HasPermutationDependentFeatures() && DataSet.GetPermutationFeatures().HasFeature(featureId)) {
27 return GetCompressedBitsFromGpuFeatures(DataSet.GetPermutationFeatures(),
28 split,
29 &DataSet.GetInverseIndices());
30 } else if (FeaturesManager.IsTreeCtr(split.FeatureId)) {
31 return CtrSplitBuilder.ComputeAndCacheCtrSplit(DataSet,
32 split);
33 } else {
34 ythrow TCatBoostException() << "Error: unknown feature";
35 }
36 }
37
38 void Split(const TBinarySplit& split,
39 TMirrorBuffer<ui32>& bins,
40 ui32 depth) final {
41 const auto& compressedBits = GetCompressedBits(split);
42 UpdateBinFromCompressedBits(compressedBits,
43 bins,
44 depth);
45 }
46
47 void SplitByExternalComputedFeature(const TBinarySplit& split,
48 const TSingleBuffer<const ui64>& compressedBits,
49 TMirrorBuffer<ui32>& dst,
50 ui32 depth) override {
51 CB_ENSURE(FeaturesManager.IsTreeCtr(split.FeatureId), "Feature id should be combinations ctr");
52
53 const auto& ctr = FeaturesManager.GetCtr(split.FeatureId);
54
55 const ui32 docCount = DataSet.GetSamplesMapping().GetObjectsSlice().Size();
56 const ui32 compressedSize = CompressedSize<ui64>(docCount, 2);
57 auto broadcastFunction = [&]() -> TMirrorBuffer<ui64> {
58 TMirrorBuffer<ui64> broadcastedBits = TMirrorBuffer<ui64>::Create(NCudaLib::TMirrorMapping(compressedSize));
59 Reshard(compressedBits, broadcastedBits);
60 return broadcastedBits;
61 };
62
63 const auto& mirrorCompressedBits = [&]() -> const TMirrorBuffer<ui64>& {
64 if (FeaturesManager.IsPermutationDependent(ctr)) {
65 return ScopedCache.Cache(DataSet.GetPermutationDependentScope(),
66 split,

Callers

nothing calls this directly

Calls 6

HasFeaturesMethod · 0.80
GetFeaturesMethod · 0.80
IsTreeCtrMethod · 0.80
HasFeatureMethod · 0.45
CacheMethod · 0.45

Tested by

no test coverage detected