Namespaces | Classes | Typedefs | Enumerations | Functions
ML::experimental::fil Namespace Reference

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{})
 

Typedef Documentation

◆ decision_forest_variant

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

◆ index_type

using ML::experimental::fil::index_type = typedef uint32_t

Enumeration Type Documentation

◆ element_op

enum ML::experimental::fil::element_op : unsigned char
strong

Enum representing possible element-wise operations on output

Enumerator
disable 
signed_square 
hinge 
sigmoid 
exponential 
logarithm_one_plus_exp 

◆ infer_kind

enum ML::experimental::fil::infer_kind : unsigned char
strong
Enumerator
default_kind 
per_tree 
leaf_id 

◆ row_op

enum ML::experimental::fil::row_op : unsigned char
strong

Enum representing possible row-wise operations on output

Enumerator
disable 
softmax 
max_index 

◆ tree_layout

enum ML::experimental::fil::tree_layout : unsigned char
strong
Enumerator
depth_first 
breadth_first 

Function Documentation

◆ get_forest_variant_index()

auto ML::experimental::fil::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 
)
inline

Determine the variant index of the decision_forest type to used based on model characteristics

Parameters
use_double_thresholdsWhether single or double-precision floating point values should be used for quantitative splits
max_node_offsetThe largest offset between a parent node and either of its children
num_featuresThe number of input features per row
num_categorical_nodesThe total number of categorical nodes in the forest
max_num_categoriesThe maximum number of categories in any categorical feature used by the model
num_vector_leavesThe 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.
layoutThe in-memory layout to be used for nodes in the forest

◆ import_from_treelite_handle()

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.

Parameters
tl_handleThe Treelite ModelHandle to load
layoutThe in-memory layout of nodes in the loaded forest
align_bytesIf 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_precisionWhether or not to use 64 bit floats for model evaluation and 64 bit ints for applicable indexing
dev_typeWhich device type to use for inference (CPU or GPU)
deviceFor GPU execution, the device id for the device on which this model is to be loaded
streamThe CUDA stream to use for loading this model (can be omitted for CPU).

◆ import_from_treelite_model()

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.

Parameters
tl_modelThe Treelite Model to load
layoutThe in-memory layout of nodes in the loaded forest
align_bytesIf 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_precisionWhether or not to use 64 bit floats for model evaluation and 64 bit ints for applicable indexing
dev_typeWhich device type to use for inference (CPU or GPU)
deviceFor GPU execution, the device id for the device on which this model is to be loaded
streamThe CUDA stream to use for loading this model (can be omitted for CPU).

◆ ops_to_val()

HOST DEVICE constexpr auto ML::experimental::fil::ops_to_val ( row_op  row_wise,
element_op  elem_wise 
)
inlineconstexpr

◆ postprocess()

template<row_op row_wise_v, element_op elem_wise_v, typename io_t >
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} 
)