@@ -63,7 +63,7 @@ bst_float PredValue(const SparsePage::Inst &inst,
63
63
psum += (*trees[i])[nidx].LeafValue ();
64
64
}
65
65
}
66
- p_feats->Drop (inst );
66
+ p_feats->Drop ();
67
67
return psum;
68
68
}
69
69
@@ -116,13 +116,11 @@ void FVecFill(const size_t block_size, const size_t batch_offset, const int num_
116
116
}
117
117
}
118
118
119
- template <typename DataView>
120
- void FVecDrop (const size_t block_size, const size_t batch_offset, DataView* batch,
121
- const size_t fvec_offset, std::vector<RegTree::FVec>* p_feats) {
119
+ void FVecDrop (std::size_t const block_size, std::size_t const fvec_offset,
120
+ std::vector<RegTree::FVec> *p_feats) {
122
121
for (size_t i = 0 ; i < block_size; ++i) {
123
122
RegTree::FVec &feats = (*p_feats)[fvec_offset + i];
124
- const SparsePage::Inst inst = (*batch)[batch_offset + i];
125
- feats.Drop (inst);
123
+ feats.Drop ();
126
124
}
127
125
}
128
126
@@ -142,11 +140,15 @@ struct SparsePageView {
142
140
struct GHistIndexMatrixView {
143
141
private:
144
142
GHistIndexMatrix const &page_;
145
- uint64_t n_features_;
143
+ std:: uint64_t const n_features_;
146
144
common::Span<FeatureType const > ft_;
147
145
common::Span<Entry> workspace_;
148
146
std::vector<size_t > current_unroll_;
149
147
148
+ std::vector<std::uint32_t > const & ptrs_;
149
+ std::vector<float > const & mins_;
150
+ std::vector<float > const & values_;
151
+
150
152
public:
151
153
size_t base_rowid;
152
154
@@ -159,6 +161,9 @@ struct GHistIndexMatrixView {
159
161
ft_{ft},
160
162
workspace_{workplace},
161
163
current_unroll_ (n_threads > 0 ? n_threads : 1 , 0 ),
164
+ ptrs_{_page.cut .Ptrs ()},
165
+ mins_{_page.cut .MinValues ()},
166
+ values_{_page.cut .Values ()},
162
167
base_rowid{_page.base_rowid } {}
163
168
164
169
SparsePage::Inst operator [](size_t r) {
@@ -167,7 +172,7 @@ struct GHistIndexMatrixView {
167
172
size_t non_missing{beg};
168
173
169
174
for (bst_feature_t c = 0 ; c < n_features_; ++c) {
170
- float f = page_.GetFvalue (r, c, common::IsCat (ft_, c));
175
+ float f = page_.GetFvalue (ptrs_, values_, mins_, r, c, common::IsCat (ft_, c));
171
176
if (!common::CheckNAN (f)) {
172
177
workspace_[non_missing] = Entry{c, f};
173
178
++non_missing;
@@ -250,10 +255,9 @@ void PredictBatchByBlockOfRowsKernel(
250
255
FVecFill (block_size, batch_offset, num_feature, &batch, fvec_offset,
251
256
p_thread_temp);
252
257
// process block of rows through all trees to keep cache locality
253
- PredictByAllTrees (model, tree_begin, tree_end, out_preds,
254
- batch_offset + batch.base_rowid , num_group, thread_temp,
255
- fvec_offset, block_size);
256
- FVecDrop (block_size, batch_offset, &batch, fvec_offset, p_thread_temp);
258
+ PredictByAllTrees (model, tree_begin, tree_end, out_preds, batch_offset + batch.base_rowid ,
259
+ num_group, thread_temp, fvec_offset, block_size);
260
+ FVecDrop (block_size, fvec_offset, p_thread_temp);
257
261
});
258
262
}
259
263
@@ -470,7 +474,7 @@ class CPUPredictor : public Predictor {
470
474
bst_node_t tid = GetLeafIndex<true , true >(tree, feats, cats);
471
475
preds[ridx * ntree_limit + j] = static_cast <bst_float>(tid);
472
476
}
473
- feats.Drop (page[i] );
477
+ feats.Drop ();
474
478
});
475
479
}
476
480
}
@@ -544,7 +548,7 @@ class CPUPredictor : public Predictor {
544
548
(tree_weights == nullptr ? 1 : (*tree_weights)[j]);
545
549
}
546
550
}
547
- feats.Drop (page[i] );
551
+ feats.Drop ();
548
552
// add base margin to BIAS
549
553
if (base_margin.Size () != 0 ) {
550
554
CHECK_EQ (base_margin.Shape (1 ), ngroup);
0 commit comments