Namespaces | |
detail | |
Classes | |
struct | decision_forest |
struct | forest |
struct | node |
struct | postprocessor |
struct | unusable_model_exception |
struct | model_import_error |
struct | type_error |
struct | forest_model |
struct | treelite_importer |
Typedefs | |
using | decision_forest_variant = std::variant< detail::preset_decision_forest< std::variant_alternative_t< 0, detail::specialization_variant >::layout, std::variant_alternative_t< 0, detail::specialization_variant >::is_double_precision, std::variant_alternative_t< 0, detail::specialization_variant >::has_large_trees >, detail::preset_decision_forest< std::variant_alternative_t< 1, detail::specialization_variant >::layout, std::variant_alternative_t< 1, detail::specialization_variant >::is_double_precision, std::variant_alternative_t< 1, detail::specialization_variant >::has_large_trees >, detail::preset_decision_forest< std::variant_alternative_t< 2, detail::specialization_variant >::layout, std::variant_alternative_t< 2, detail::specialization_variant >::is_double_precision, std::variant_alternative_t< 2, detail::specialization_variant >::has_large_trees >, detail::preset_decision_forest< std::variant_alternative_t< 3, detail::specialization_variant >::layout, std::variant_alternative_t< 3, detail::specialization_variant >::is_double_precision, std::variant_alternative_t< 3, detail::specialization_variant >::has_large_trees >, detail::preset_decision_forest< std::variant_alternative_t< 4, detail::specialization_variant >::layout, std::variant_alternative_t< 4, detail::specialization_variant >::is_double_precision, std::variant_alternative_t< 4, detail::specialization_variant >::has_large_trees >, detail::preset_decision_forest< std::variant_alternative_t< 5, detail::specialization_variant >::layout, std::variant_alternative_t< 5, detail::specialization_variant >::is_double_precision, std::variant_alternative_t< 5, detail::specialization_variant >::has_large_trees >, detail::preset_decision_forest< std::variant_alternative_t< 6, detail::specialization_variant >::layout, std::variant_alternative_t< 6, detail::specialization_variant >::is_double_precision, std::variant_alternative_t< 6, detail::specialization_variant >::has_large_trees >, detail::preset_decision_forest< std::variant_alternative_t< 7, detail::specialization_variant >::layout, std::variant_alternative_t< 7, detail::specialization_variant >::is_double_precision, std::variant_alternative_t< 7, detail::specialization_variant >::has_large_trees > > |
using | index_type = uint32_t |
Enumerations | |
enum class | infer_kind : unsigned char { default_kind = 0 , per_tree = 1 , leaf_id = 2 } |
enum class | row_op : unsigned char { disable = 0b00100000 , softmax = 0b01000000 , max_index = 0b10000000 } |
enum class | element_op : unsigned char { disable = 0b00000000 , signed_square = 0b00000001 , hinge = 0b00000010 , sigmoid = 0b00000100 , exponential = 0b00001000 , logarithm_one_plus_exp = 0b00010000 } |
enum class | tree_layout : unsigned char { depth_first = 0 , breadth_first = 1 } |
Functions | |
auto | get_forest_variant_index (bool use_double_thresholds, index_type max_node_offset, index_type num_features, index_type num_categorical_nodes=index_type{}, index_type max_num_categories=index_type{}, index_type num_vector_leaves=index_type{}, tree_layout layout=preferred_tree_layout) |
HOST DEVICE constexpr auto | ops_to_val (row_op row_wise, element_op elem_wise) |
template<row_op row_wise_v, element_op elem_wise_v, typename io_t > | |
HOST DEVICE void | postprocess (io_t *val, index_type output_count, io_t *out, index_type stride=index_type{1}, io_t average_factor=io_t{1}, io_t bias=io_t{0}, io_t constant=io_t{1}) |
auto | import_from_treelite_model (treelite::Model const &tl_model, tree_layout layout=preferred_tree_layout, index_type align_bytes=index_type{}, std::optional< bool > use_double_precision=std::nullopt, raft_proto::device_type dev_type=raft_proto::device_type::cpu, int device=0, raft_proto::cuda_stream stream=raft_proto::cuda_stream{}) |
auto | import_from_treelite_handle (TreeliteModelHandle tl_handle, tree_layout layout=preferred_tree_layout, index_type align_bytes=index_type{}, std::optional< bool > use_double_precision=std::nullopt, raft_proto::device_type dev_type=raft_proto::device_type::cpu, int device=0, raft_proto::cuda_stream stream=raft_proto::cuda_stream{}) |
using ML::experimental::fil::decision_forest_variant = typedef std::variant<detail::preset_decision_forest< std::variant_alternative_t<0, detail::specialization_variant>::layout, std::variant_alternative_t<0, detail::specialization_variant>::is_double_precision, std::variant_alternative_t<0, detail::specialization_variant>::has_large_trees>, detail::preset_decision_forest< std::variant_alternative_t<1, detail::specialization_variant>::layout, std::variant_alternative_t<1, detail::specialization_variant>::is_double_precision, std::variant_alternative_t<1, detail::specialization_variant>::has_large_trees>, detail::preset_decision_forest< std::variant_alternative_t<2, detail::specialization_variant>::layout, std::variant_alternative_t<2, detail::specialization_variant>::is_double_precision, std::variant_alternative_t<2, detail::specialization_variant>::has_large_trees>, detail::preset_decision_forest< std::variant_alternative_t<3, detail::specialization_variant>::layout, std::variant_alternative_t<3, detail::specialization_variant>::is_double_precision, std::variant_alternative_t<3, detail::specialization_variant>::has_large_trees>, detail::preset_decision_forest< std::variant_alternative_t<4, detail::specialization_variant>::layout, std::variant_alternative_t<4, detail::specialization_variant>::is_double_precision, std::variant_alternative_t<4, detail::specialization_variant>::has_large_trees>, detail::preset_decision_forest< std::variant_alternative_t<5, detail::specialization_variant>::layout, std::variant_alternative_t<5, detail::specialization_variant>::is_double_precision, std::variant_alternative_t<5, detail::specialization_variant>::has_large_trees>, detail::preset_decision_forest< std::variant_alternative_t<6, detail::specialization_variant>::layout, std::variant_alternative_t<6, detail::specialization_variant>::is_double_precision, std::variant_alternative_t<6, detail::specialization_variant>::has_large_trees>, detail::preset_decision_forest< std::variant_alternative_t<7, detail::specialization_variant>::layout, std::variant_alternative_t<7, detail::specialization_variant>::is_double_precision, std::variant_alternative_t<7, detail::specialization_variant>::has_large_trees> > |
A variant containing all standard decision_forest instantiations
using ML::experimental::fil::index_type = typedef uint32_t |
|
strong |
|
strong |
|
strong |
|
strong |
|
inline |
Determine the variant index of the decision_forest type to used based on model characteristics
use_double_thresholds | Whether single or double-precision floating point values should be used for quantitative splits |
max_node_offset | The largest offset between a parent node and either of its children |
num_features | The number of input features per row |
num_categorical_nodes | The total number of categorical nodes in the forest |
max_num_categories | The maximum number of categories in any categorical feature used by the model |
num_vector_leaves | The total number of leaf nodes which produce vector outputs. For non-vector-leaf models, this should be 0. For vector-leaf models, this should be the total number of leaf nodes. |
layout | The in-memory layout to be used for nodes in the forest |
auto ML::experimental::fil::import_from_treelite_handle | ( | TreeliteModelHandle | tl_handle, |
tree_layout | layout = preferred_tree_layout , |
||
index_type | align_bytes = index_type{} , |
||
std::optional< bool > | use_double_precision = std::nullopt , |
||
raft_proto::device_type | dev_type = raft_proto::device_type::cpu , |
||
int | device = 0 , |
||
raft_proto::cuda_stream | stream = raft_proto::cuda_stream{} |
||
) |
Import a treelite model handle to FIL
Load a model from a Treelite model handle (type-erased treelite::Model object) to a FIL forest_model. The model will be inspected to determine the correct underlying decision_forest variant to use within the forest_model object.
tl_handle | The Treelite ModelHandle to load |
layout | The in-memory layout of nodes in the loaded forest |
align_bytes | If non-zero, ensure that each tree is stored in a multiple of this value of bytes by padding with empty nodes. This can be useful for increasing the likelihood that successive reads will take place within a single cache line. On GPU, a value of 128 can be used for this purpose. On CPU, a value of either 0 or 64 typically produces optimal performance. |
use_double_precision | Whether or not to use 64 bit floats for model evaluation and 64 bit ints for applicable indexing |
dev_type | Which device type to use for inference (CPU or GPU) |
device | For GPU execution, the device id for the device on which this model is to be loaded |
stream | The CUDA stream to use for loading this model (can be omitted for CPU). |
auto ML::experimental::fil::import_from_treelite_model | ( | treelite::Model const & | tl_model, |
tree_layout | layout = preferred_tree_layout , |
||
index_type | align_bytes = index_type{} , |
||
std::optional< bool > | use_double_precision = std::nullopt , |
||
raft_proto::device_type | dev_type = raft_proto::device_type::cpu , |
||
int | device = 0 , |
||
raft_proto::cuda_stream | stream = raft_proto::cuda_stream{} |
||
) |
Import a treelite model to FIL
Load a model from Treelite to a FIL forest_model. The model will be inspected to determine the correct underlying decision_forest variant to use within the forest_model object.
tl_model | The Treelite Model to load |
layout | The in-memory layout of nodes in the loaded forest |
align_bytes | If non-zero, ensure that each tree is stored in a multiple of this value of bytes by padding with empty nodes. This can be useful for increasing the likelihood that successive reads will take place within a single cache line. On GPU, a value of 128 can be used for this purpose. On CPU, a value of either 0 or 64 typically produces optimal performance. |
use_double_precision | Whether or not to use 64 bit floats for model evaluation and 64 bit ints for applicable indexing |
dev_type | Which device type to use for inference (CPU or GPU) |
device | For GPU execution, the device id for the device on which this model is to be loaded |
stream | The CUDA stream to use for loading this model (can be omitted for CPU). |
|
inlineconstexpr |
HOST DEVICE void ML::experimental::fil::postprocess | ( | io_t * | val, |
index_type | output_count, | ||
io_t * | out, | ||
index_type | stride = index_type{1} , |
||
io_t | average_factor = io_t{1} , |
||
io_t | bias = io_t{0} , |
||
io_t | constant = io_t{1} |
||
) |