Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement vector leaf prediction for fil. #3917

Merged
merged 17 commits into from
Jun 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions cpp/src/fil/common.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,19 @@ struct dense_tree {
/** dense_storage stores the forest as a collection of dense nodes */
struct dense_storage {
__host__ __device__ dense_storage(dense_node* nodes, int num_trees,
int tree_stride, int node_pitch)
int tree_stride, int node_pitch,
float* vector_leaf)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given how much fields dense_storage and sparse_storage share, consider adding base_storage as the base type for both containing the common fields and implementation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it would also help categorical features in the future

: nodes_(nodes),
num_trees_(num_trees),
tree_stride_(tree_stride),
node_pitch_(node_pitch) {}
node_pitch_(node_pitch),
vector_leaf_(vector_leaf) {}
__host__ __device__ int num_trees() const { return num_trees_; }
__host__ __device__ dense_tree operator[](int i) const {
return dense_tree(nodes_ + i * tree_stride_, node_pitch_);
}
dense_node* nodes_ = nullptr;
float* vector_leaf_ = nullptr;
int num_trees_ = 0;
int tree_stride_ = 0;
int node_pitch_ = 0;
Expand All @@ -93,9 +96,14 @@ template <typename node_t>
struct sparse_storage {
int* trees_ = nullptr;
node_t* nodes_ = nullptr;
float* vector_leaf_ = nullptr;
int num_trees_ = 0;
__host__ __device__ sparse_storage(int* trees, node_t* nodes, int num_trees)
: trees_(trees), nodes_(nodes), num_trees_(num_trees) {}
__host__ __device__ sparse_storage(int* trees, node_t* nodes, int num_trees,
float* vector_leaf)
: trees_(trees),
nodes_(nodes),
num_trees_(num_trees),
vector_leaf_(vector_leaf) {}
__host__ __device__ int num_trees() const { return num_trees_; }
__host__ __device__ sparse_tree<node_t> operator[](int i) const {
return sparse_tree<node_t>(&nodes_[trees_[i]]);
Expand Down
Loading