treelite
Classes | Enumerations | Functions
treelite::gtil Namespace Reference

Classes

struct  Configuration
 Configuration class. More...
 

Enumerations

enum class  PredictKind : std::int8_t { kPredictDefault = 0 , kPredictRaw = 1 , kPredictLeafID = 2 , kPredictPerTree = 3 }
 Prediction type. More...
 

Functions

template<typename InputT >
void Predict (Model const &model, InputT const *input, std::uint64_t num_row, InputT *output, Configuration const &config)
 Predict with dense data. More...
 
template<typename InputT >
void PredictSparse (Model const &model, InputT const *data, std::uint64_t const *col_ind, std::uint64_t const *row_ptr, std::uint64_t num_row, InputT *output, Configuration const &config)
 Predict with sparse data with CSR (compressed sparse row) layout. More...
 
std::vector< std::uint64_t > GetOutputShape (Model const &model, std::uint64_t num_row, Configuration const &config)
 Given a data matrix, query the necessary shape of array to hold predictions for all data points. More...
 
template void Predict< float > (Model const &, float const *, std::uint64_t, float *, Configuration const &)
 
template void Predict< double > (Model const &, double const *, std::uint64_t, double *, Configuration const &)
 
template void PredictSparse< float > (Model const &, float const *, std::uint64_t const *, std::uint64_t const *, std::uint64_t, float *, Configuration const &)
 
template void PredictSparse< double > (Model const &, double const *, std::uint64_t const *, std::uint64_t const *, std::uint64_t, double *, Configuration const &)
 

Enumeration Type Documentation

◆ PredictKind

enum treelite::gtil::PredictKind : std::int8_t
strong

Prediction type.

Enumerator
kPredictDefault 

Usual prediction method: sum over trees and apply post-processing. Expected output dimensions: (num_row, num_target, max_num_class)

kPredictRaw 

Sum over trees, but don't apply post-processing; get raw margin scores instead. Expected output dimensions: (num_row, num_target, max_num_class)

kPredictLeafID 

Output one (integer) leaf ID per tree. Expected output dimensions: (num_row, num_tree)

kPredictPerTree 

Output one or more margin scores per tree. Expected output dimensions: (num_row, num_tree, leaf_vector_shape[0] * leaf_vector_shape[1])

Function Documentation

◆ GetOutputShape()

std::vector<std::uint64_t> treelite::gtil::GetOutputShape ( Model const &  model,
std::uint64_t  num_row,
Configuration const &  config 
)

Given a data matrix, query the necessary shape of array to hold predictions for all data points.

Parameters
modelTreelite Model object
num_rowNumber of rows in the input
configConfiguration of GTIL predictor. Set this by calling TreeliteGTILParseConfig.
Returns
Array shape

◆ Predict()

template<typename InputT >
void treelite::gtil::Predict ( Model const &  model,
InputT const *  input,
std::uint64_t  num_row,
InputT *  output,
Configuration const &  config 
)

Predict with dense data.

Parameters
modelTreelite Model object
inputThe 2D data array, laid out in row-major layout
num_rowNumber of rows in the data matrix.
outputPointer to buffer to store the output. Call GetOutputShape to get the amount of buffer you should allocate for this parameter.
configConfiguration of GTIL predictor

◆ Predict< double >()

template void treelite::gtil::Predict< double > ( Model const &  ,
double const *  ,
std::uint64_t  ,
double *  ,
Configuration const &   
)

◆ Predict< float >()

template void treelite::gtil::Predict< float > ( Model const &  ,
float const *  ,
std::uint64_t  ,
float *  ,
Configuration const &   
)

◆ PredictSparse()

template<typename InputT >
void treelite::gtil::PredictSparse ( Model const &  model,
InputT const *  data,
std::uint64_t const *  col_ind,
std::uint64_t const *  row_ptr,
std::uint64_t  num_row,
InputT *  output,
Configuration const &  config 
)

Predict with sparse data with CSR (compressed sparse row) layout.

In the CSR layout, data[row_ptr[i]:row_ptr[i+1]] store the nonzero entries of row i, and col_ind[row_ptr[i]:row_ptr[i+1]] stores the corresponding column indices.

Parameters
modelTreelite Model object
dataNonzero elements in the data matrix
col_indFeature indices. col_ind[i] indicates the feature index associated with data[i].
row_ptrPointer to row headers. Length is [num_row] + 1.
num_rowNumber of rows in the data matrix.
outputPointer to buffer to store the output. Call GetOutputShape to get the amount of buffer you should allocate for this parameter.
configConfiguration of GTIL predictor

◆ PredictSparse< double >()

template void treelite::gtil::PredictSparse< double > ( Model const &  ,
double const *  ,
std::uint64_t const *  ,
std::uint64_t const *  ,
std::uint64_t  ,
double *  ,
Configuration const &   
)

◆ PredictSparse< float >()

template void treelite::gtil::PredictSparse< float > ( Model const &  ,
float const *  ,
std::uint64_t const *  ,
std::uint64_t const *  ,
std::uint64_t  ,
float *  ,
Configuration const &   
)