23 #include <type_traits>
26 namespace experimental {
34 template <
typename threshold_t,
typename index_t,
typename metadata_storage_t,
typename offset_t>
38 sizeof(metadata_storage_t) +
sizeof(offset_t));
40 if (total > result) { result =
index_type{16}; }
41 if (total > result) { result =
index_type{32}; }
42 if (total > result) { result =
index_type{64}; }
43 if (total > result) { result =
index_type{128}; }
44 if (total > result) { result =
index_type{256}; }
45 if (total > result) { result = total; }
90 typename metadata_storage_t,
94 detail::get_node_alignment<threshold_t, index_t, metadata_storage_t, offset_t>())
node {
96 auto constexpr
static const layout = layout_v;
120 #pragma GCC diagnostic push
121 #pragma GCC diagnostic ignored "-Wnarrowing"
123 bool is_leaf_node =
true,
124 bool default_to_distant_child =
false,
125 bool is_categorical_node =
false,
131 distant_child_offset,
132 construct_metadata(is_leaf_node, default_to_distant_child, is_categorical_node, feature)}}
137 bool is_leaf_node =
true,
138 bool default_to_distant_child =
false,
139 bool is_categorical_node =
false,
145 distant_child_offset,
146 construct_metadata(is_leaf_node, default_to_distant_child, is_categorical_node, feature)}}
149 #pragma GCC diagnostic pop
154 return aligned_data.inner_data.metadata & FEATURE_MASK;
159 return !bool(aligned_data.inner_data.distant_offset);
164 return bool(aligned_data.inner_data.metadata & DEFAULT_DISTANT_MASK);
169 return bool(aligned_data.inner_data.metadata & CATEGORICAL_MASK);
185 return aligned_data.inner_data.stored_value.value;
189 HOST DEVICE auto const&
index()
const {
return aligned_data.inner_data.stored_value.index; }
194 template <
bool has_vector_leaves>
197 if constexpr (has_vector_leaves) {
198 return aligned_data.inner_data.stored_value.index;
200 return aligned_data.inner_data.stored_value.value;
211 auto constexpr
static const LEAF_BIT =
215 auto constexpr
static const DEFAULT_DISTANT_MASK =
219 auto constexpr
static const FEATURE_MASK =
223 auto static constexpr construct_metadata(
bool is_leaf_node =
true,
224 bool default_to_distant_child =
false,
225 bool is_categorical_node =
false,
229 (is_leaf_node << LEAF_BIT) + (default_to_distant_child << DEFAULT_DISTANT_BIT) +
230 (is_categorical_node << CATEGORICAL_BIT) + (feature & FEATURE_MASK));
233 auto static constexpr
const byte_size =
234 detail::get_node_alignment<threshold_t, index_t, metadata_storage_t, offset_t>();
236 struct inner_data_type {
237 value_type stored_value;
243 union aligned_data_type {
244 inner_data_type inner_data;
245 char spacer_data[byte_size];
248 aligned_data_type aligned_data;
}
#define DEVICE
Definition: gpu_support.hpp:35
#define HOST
Definition: gpu_support.hpp:34
math_t max(math_t a, math_t b)
Definition: learning_rate.h:27
constexpr auto get_node_alignment()
Definition: node.hpp:35
tree_layout
Definition: tree_layout.hpp:20
uint32_t index_type
Definition: index_type.hpp:21
Definition: dbscan.hpp:30
HOST DEVICE constexpr auto default_distant() const
Definition: node.hpp:161
HOST DEVICE constexpr auto threshold() const
Definition: node.hpp:182
HOST DEVICE constexpr auto is_categorical() const
Definition: node.hpp:166
HOST DEVICE constexpr auto child_offset(bool condition) const
Definition: node.hpp:171
HOST DEVICE constexpr auto output() const
Definition: node.hpp:194
threshold_t threshold_type
Definition: node.hpp:97
metadata_storage_t metadata_storage_type
An alias for metadata_storage_t.
Definition: node.hpp:113
HOST DEVICE constexpr auto is_leaf() const
Definition: node.hpp:156
HOST DEVICE auto const & index() const
Definition: node.hpp:188
HOST DEVICE constexpr auto feature_index() const
Definition: node.hpp:151
HOST constexpr DEVICE node(threshold_type value=threshold_type{}, bool is_leaf_node=true, bool default_to_distant_child=false, bool is_categorical_node=false, metadata_storage_type feature=metadata_storage_type{}, offset_type distant_child_offset=offset_type{})
Definition: node.hpp:121
index_t index_type
Definition: node.hpp:99
constexpr static auto const layout
Definition: node.hpp:95
offset_t offset_type
An alias for offset_t.
Definition: node.hpp:115
threshold_t value
Definition: node.hpp:109
index_t index
Definition: node.hpp:110