forest_macros.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023-2024, NVIDIA CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #pragma once
21 
22 #include <variant>
23 
24 /* Macro which, given a variant index, will extract the type of the
25  * corresponding variant from the specialization_variant type. This allows us
26  * to specify all forest variants we wish to support in one location and then
27  * reference them by index elsewhere. */
28 #define CUML_FIL_SPEC(variant_index) \
29  std::variant_alternative_t<variant_index, fil::detail::specialization_variant>
30 
31 /* Macro which expands to a full declaration of a forest type corresponding to
32  * the given variant index. */
33 #define CUML_FIL_FOREST(variant_index) \
34  forest<CUML_FIL_SPEC(variant_index)::layout, \
35  typename CUML_FIL_SPEC(variant_index)::threshold_type, \
36  typename CUML_FIL_SPEC(variant_index)::index_type, \
37  typename CUML_FIL_SPEC(variant_index)::metadata_type, \
38  typename CUML_FIL_SPEC(variant_index)::offset_type>