@@ -201,7 +201,7 @@ void RowsWiseBuildHistKernel(Span<GradientPair const> gpair,
201
201
202
202
auto const &row_ptr = gmat.row_ptr .data ();
203
203
auto base_rowid = gmat.base_rowid ;
204
- uint32_t const *offsets = gmat.index .Offset ();
204
+ std:: uint32_t const *offsets = gmat.index .Offset ();
205
205
// There's no feature-based compression if missing value is present.
206
206
if (kAnyMissing ) {
207
207
CHECK (!offsets);
@@ -212,8 +212,11 @@ void RowsWiseBuildHistKernel(Span<GradientPair const> gpair,
212
212
auto get_row_ptr = [&](bst_idx_t ridx) {
213
213
return kFirstPage ? row_ptr[ridx] : row_ptr[ridx - base_rowid];
214
214
};
215
- auto get_rid = [&](bst_idx_t ridx) { return kFirstPage ? ridx : (ridx - base_rowid); };
215
+ auto get_rid = [&](bst_idx_t ridx) {
216
+ return kFirstPage ? ridx : (ridx - base_rowid);
217
+ };
216
218
219
+ CHECK_NE (row_indices.Size (), 0 );
217
220
const size_t n_features =
218
221
get_row_ptr (row_indices.begin [0 ] + 1 ) - get_row_ptr (row_indices.begin [0 ]);
219
222
auto hist_data = reinterpret_cast <double *>(hist.data ());
@@ -325,16 +328,20 @@ void BuildHistDispatch(Span<GradientPair const> gpair, const RowSetCollection::E
325
328
326
329
if (contiguousBlock) {
327
330
// contiguous memory access, built-in HW prefetching is enough
331
+ if (row_indices.Size () == 0 ) {
332
+ return ;
333
+ }
328
334
RowsWiseBuildHistKernel<false , BuildingManager>(gpair, row_indices, gmat, hist);
329
335
} else {
330
- const RowSetCollection::Elem span1 (row_indices.begin ,
331
- row_indices.end - no_prefetch_size);
332
- const RowSetCollection::Elem span2 (row_indices.end - no_prefetch_size,
333
- row_indices.end );
334
-
335
- RowsWiseBuildHistKernel<true , BuildingManager>(gpair, span1, gmat, hist);
336
+ const RowSetCollection::Elem span1 (row_indices.begin , row_indices.end - no_prefetch_size);
337
+ if (span1.Size () != 0 ) {
338
+ RowsWiseBuildHistKernel<true , BuildingManager>(gpair, span1, gmat, hist);
339
+ }
336
340
// no prefetching to avoid loading extra memory
337
- RowsWiseBuildHistKernel<false , BuildingManager>(gpair, span2, gmat, hist);
341
+ const RowSetCollection::Elem span2 (row_indices.end - no_prefetch_size, row_indices.end );
342
+ if (span2.Size () != 0 ) {
343
+ RowsWiseBuildHistKernel<false , BuildingManager>(gpair, span2, gmat, hist);
344
+ }
338
345
}
339
346
}
340
347
}
0 commit comments