Skip to content

Commit

Permalink
Move into cpu predictor.
Browse files Browse the repository at this point in the history
  • Loading branch information
trivialfis committed Jun 1, 2021
1 parent c3c82e4 commit 4f444c2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
14 changes: 14 additions & 0 deletions src/predictor/cpu_predictor.cc
Expand Up @@ -28,6 +28,20 @@ namespace predictor {

DMLC_REGISTRY_FILE_TAG(cpu_predictor);

template <bool has_missing, bool has_categorical>
bst_node_t GetLeafIndex(RegTree const &tree, const RegTree::FVec &feat,
RegTree::CategoricalSplitMatrix const& cats) {
bst_node_t nid = 0;
while (!tree[nid].IsLeaf()) {
unsigned split_index = tree[nid].SplitIndex();
auto fvalue = feat.GetFvalue(split_index);
auto nodes = common::Span<RegTree::Node const>{tree.GetNodes()};
nid = GetNextNode<has_missing, has_categorical>(
nodes, nid, fvalue, has_missing && feat.IsMissing(split_index), cats);
}
return nid;
}

bst_float PredValue(const SparsePage::Inst &inst,
const std::vector<std::unique_ptr<RegTree>> &trees,
const std::vector<int> &tree_info, int bst_group,
Expand Down
14 changes: 0 additions & 14 deletions src/predictor/predict_fn.h
Expand Up @@ -31,20 +31,6 @@ inline XGBOOST_DEVICE bst_node_t GetNextNode(
}
return nid;
}

template <bool has_missing, bool has_categorical>
bst_node_t GetLeafIndex(RegTree const &tree, const RegTree::FVec &feat,
RegTree::CategoricalSplitMatrix const& cats) {
bst_node_t nid = 0;
while (!tree[nid].IsLeaf()) {
unsigned split_index = tree[nid].SplitIndex();
auto fvalue = feat.GetFvalue(split_index);
auto nodes = common::Span<RegTree::Node const>{tree.GetNodes()};
nid = GetNextNode<has_missing, has_categorical>(
nodes, nid, fvalue, has_missing && feat.IsMissing(split_index), cats);
}
return nid;
}
} // namespace predictor
} // namespace xgboost
#endif // XGBOOST_PREDICTOR_PREDICT_FN_H_

0 comments on commit 4f444c2

Please sign in to comment.