@@ -30,29 +30,42 @@ namespace legateboost {
30
30
namespace {
31
31
32
32
class BinnedX {
33
- // We could use int16 here if we store the indices offset from their minimum value
34
- std::vector<int32_t > data;
33
+ // These are stored as int16_t to save space
34
+ // Indices are relative to the feature, not the entire histogram
35
+ // The maximum number of bins in legate-boost is 2048
36
+ legate::Buffer<int16_t > data;
35
37
36
38
public:
37
39
legate::Rect <3 > shape;
40
+ legate::Buffer<int32_t > row_pointers;
38
41
int64_t num_features;
39
42
int64_t num_rows;
40
43
template <typename T>
41
44
BinnedX (legate::AccessorRO<T, 3 > X,
42
45
legate::Rect <3 > shape,
43
46
const SparseSplitProposals<T>& split_proposals)
44
47
: shape(shape),
45
- num_features (shape.hi[1 ] - shape.lo[1 ] + 1 ),
46
- num_rows(shape.hi[0 ] - shape.lo[0 ] + 1 )
48
+ row_pointers (legate::create_buffer<int32_t , 1 >(split_proposals.row_pointers.size())),
49
+ num_features(std::max(shape.hi[1 ] - shape.lo[1 ] + 1 , 0ll )),
50
+ num_rows(std::max(shape.hi[0 ] - shape.lo[0 ] + 1 , 0ll ))
47
51
{
48
- data.resize (num_features * num_rows);
52
+ data = legate::create_buffer<int16_t >(num_features * num_rows);
53
+ std::copy (split_proposals.row_pointers .begin (),
54
+ split_proposals.row_pointers .end (),
55
+ row_pointers.ptr (0 ));
49
56
for (int i = 0 ; i < num_rows; i++) {
50
57
for (int j = 0 ; j < num_features; j++) {
51
- data[i * num_features + j] = split_proposals.FindBin (X[{i, j, 0 }], j);
58
+ auto bin_idx = split_proposals.FindBin (X[{i, j, 0 }], j);
59
+ // Store the bin index relative to the feature to save space
60
+ data[i * num_features + j] = bin_idx - row_pointers[j];
52
61
}
53
62
}
54
63
}
55
- int64_t operator [](const legate::Point <2 >& p) const { return data[p[0 ] * num_features + p[1 ]]; }
64
+ // This should use the local row index, not global
65
+ int64_t operator [](const legate::Point <2 >& p) const
66
+ {
67
+ return data[p[0 ] * num_features + p[1 ]] + row_pointers[p[1 ]];
68
+ }
56
69
};
57
70
58
71
struct NodeBatch {
@@ -194,6 +207,8 @@ auto SelectSplitSamples(legate::TaskContext context,
194
207
split_proposals_tmp.insert (split_proposals_tmp.end (), unique.begin (), unique.end ());
195
208
}
196
209
210
+ draft_proposals.destroy ();
211
+
197
212
auto split_proposals = legate::create_buffer<T, 1 >(split_proposals_tmp.size ());
198
213
std::copy (split_proposals_tmp.begin (), split_proposals_tmp.end (), split_proposals.ptr (0 ));
199
214
0 commit comments