From 4f444c209b73fde81675f45f7d2060a936cae07d Mon Sep 17 00:00:00 2001 From: fis Date: Tue, 1 Jun 2021 18:15:30 +0800 Subject: [PATCH] Move into cpu predictor. --- src/predictor/cpu_predictor.cc | 14 ++++++++++++++ src/predictor/predict_fn.h | 14 -------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/predictor/cpu_predictor.cc b/src/predictor/cpu_predictor.cc index d95bdf583a04..4fb28f7eb3e9 100644 --- a/src/predictor/cpu_predictor.cc +++ b/src/predictor/cpu_predictor.cc @@ -28,6 +28,20 @@ namespace predictor { DMLC_REGISTRY_FILE_TAG(cpu_predictor); +template +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{tree.GetNodes()}; + nid = GetNextNode( + nodes, nid, fvalue, has_missing && feat.IsMissing(split_index), cats); + } + return nid; +} + bst_float PredValue(const SparsePage::Inst &inst, const std::vector> &trees, const std::vector &tree_info, int bst_group, diff --git a/src/predictor/predict_fn.h b/src/predictor/predict_fn.h index 76851f160b24..f40b2e029e26 100644 --- a/src/predictor/predict_fn.h +++ b/src/predictor/predict_fn.h @@ -31,20 +31,6 @@ inline XGBOOST_DEVICE bst_node_t GetNextNode( } return nid; } - -template -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{tree.GetNodes()}; - nid = GetNextNode( - nodes, nid, fvalue, has_missing && feat.IsMissing(split_index), cats); - } - return nid; -} } // namespace predictor } // namespace xgboost #endif // XGBOOST_PREDICTOR_PREDICT_FN_H_