21 #include <type_traits>
24 namespace experimental {
32 template <
typename threshold_t,
typename index_t,
typename metadata_storage_t,
typename offset_t>
36 sizeof(metadata_storage_t) +
sizeof(offset_t));
38 if (total > result) { result =
index_type{16}; }
39 if (total > result) { result =
index_type{32}; }
40 if (total > result) { result =
index_type{64}; }
41 if (total > result) { result =
index_type{128}; }
42 if (total > result) { result =
index_type{256}; }
43 if (total > result) { result = total; }
88 typename metadata_storage_t,
92 detail::get_node_alignment<threshold_t, index_t, metadata_storage_t, offset_t>())
node {
94 auto constexpr
static const layout = layout_v;
118 #pragma GCC diagnostic push
119 #pragma GCC diagnostic ignored "-Wnarrowing"
121 bool is_leaf_node =
true,
122 bool default_to_distant_child =
false,
123 bool is_categorical_node =
false,
129 distant_child_offset,
130 construct_metadata(is_leaf_node, default_to_distant_child, is_categorical_node, feature)}}
135 bool is_leaf_node =
true,
136 bool default_to_distant_child =
false,
137 bool is_categorical_node =
false,
143 distant_child_offset,
144 construct_metadata(is_leaf_node, default_to_distant_child, is_categorical_node, feature)}}
147 #pragma GCC diagnostic pop
152 return aligned_data.inner_data.metadata & FEATURE_MASK;
157 return !bool(aligned_data.inner_data.distant_offset);
162 return bool(aligned_data.inner_data.metadata & DEFAULT_DISTANT_MASK);
167 return bool(aligned_data.inner_data.metadata & CATEGORICAL_MASK);
183 return aligned_data.inner_data.stored_value.value;
187 HOST DEVICE auto const&
index()
const {
return aligned_data.inner_data.stored_value.index; }
192 template <
bool has_vector_leaves>
195 if constexpr (has_vector_leaves) {
196 return aligned_data.inner_data.stored_value.index;
198 return aligned_data.inner_data.stored_value.value;
209 auto constexpr
static const LEAF_BIT =
213 auto constexpr
static const DEFAULT_DISTANT_MASK =
217 auto constexpr
static const FEATURE_MASK =
221 auto static constexpr construct_metadata(
bool is_leaf_node =
true,
222 bool default_to_distant_child =
false,
223 bool is_categorical_node =
false,
227 (is_leaf_node << LEAF_BIT) + (default_to_distant_child << DEFAULT_DISTANT_BIT) +
228 (is_categorical_node << CATEGORICAL_BIT) + (feature & FEATURE_MASK));
231 auto static constexpr
const byte_size =
232 detail::get_node_alignment<threshold_t, index_t, metadata_storage_t, offset_t>();
234 struct inner_data_type {
235 value_type stored_value;
241 union aligned_data_type {
242 inner_data_type inner_data;
243 char spacer_data[byte_size];
246 aligned_data_type aligned_data;
}
#define DEVICE
Definition: gpu_support.hpp:34
#define HOST
Definition: gpu_support.hpp:33
math_t max(math_t a, math_t b)
Definition: learning_rate.h:26
constexpr auto get_node_alignment()
Definition: node.hpp:33
tree_layout
Definition: tree_layout.hpp:20
uint32_t index_type
Definition: index_type.hpp:21
Definition: dbscan.hpp:27
HOST DEVICE constexpr auto default_distant() const
Definition: node.hpp:159
HOST DEVICE constexpr auto threshold() const
Definition: node.hpp:180
HOST DEVICE constexpr auto is_categorical() const
Definition: node.hpp:164
HOST DEVICE constexpr auto child_offset(bool condition) const
Definition: node.hpp:169
HOST DEVICE constexpr auto output() const
Definition: node.hpp:192
threshold_t threshold_type
Definition: node.hpp:95
metadata_storage_t metadata_storage_type
An alias for metadata_storage_t.
Definition: node.hpp:111
HOST DEVICE constexpr auto is_leaf() const
Definition: node.hpp:154
HOST DEVICE auto const & index() const
Definition: node.hpp:186
HOST DEVICE constexpr auto feature_index() const
Definition: node.hpp:149
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:119
index_t index_type
Definition: node.hpp:97
constexpr static auto const layout
Definition: node.hpp:93
offset_t offset_type
An alias for offset_t.
Definition: node.hpp:113
threshold_t value
Definition: node.hpp:107
index_t index
Definition: node.hpp:108