Treelite
Functions
gtil.h File Reference

General Tree Inference Library (GTIL), providing a reference implementation for predicting with decision trees. GTIL is useful in cases it is infeasible to build the tree models as native shared libs. More...

#include <cstddef>
Include dependency graph for gtil.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

std::size_t Predict (const Model *model, const DMatrix *input, float *output, int nthread, bool pred_transform)
 Predict with a DMatrix. More...
 
std::size_t Predict (const Model *model, const float *input, std::size_t num_row, float *output, int nthread, bool pred_transform)
 Predict with a 2D dense array. More...
 
std::size_t GetPredictOutputSize (const Model *model, std::size_t num_row)
 Given a batch of data rows, query the necessary size of array to hold predictions for all data points. More...
 
std::size_t GetPredictOutputSize (const Model *model, const DMatrix *input)
 Given a batch of data rows, query the necessary size of array to hold predictions for all data points. More...
 

Detailed Description

General Tree Inference Library (GTIL), providing a reference implementation for predicting with decision trees. GTIL is useful in cases it is infeasible to build the tree models as native shared libs.

Copyright (c) 2021 by Contributors

Author
Hyunsu Cho

Definition in file gtil.h.

Function Documentation

◆ GetPredictOutputSize() [1/2]

std::size_t GetPredictOutputSize ( const Model model,
std::size_t  num_row 
)

Given a batch of data rows, query the necessary size of array to hold predictions for all data points.

Parameters
modelTreelite Model object
num_rowNumber of rows in the input
Returns
Size of output buffer that should be allocated

Definition at line 479 of file predict.cc.

◆ GetPredictOutputSize() [2/2]

std::size_t GetPredictOutputSize ( const Model model,
const DMatrix input 
)

Given a batch of data rows, query the necessary size of array to hold predictions for all data points.

Parameters
modelTreelite Model object
inputThe input matrix
Returns
Size of output buffer that should be allocated

Definition at line 483 of file predict.cc.

◆ Predict() [1/2]

std::size_t Predict ( const Model model,
const DMatrix input,
float *  output,
int  nthread,
bool  pred_transform 
)

Predict with a DMatrix.

Parameters
modelThe model object
inputThe data matrix (sparse or dense)
outputPointer to buffer to store the output. Call GetPredictOutputSize() to get the amount of buffer you should allocate for this parameter.
nthreadnumber of CPU threads to use. Set <= 0 to use all CPU cores.
pred_transformAfter computing the prediction score, whether to transform it.
Returns
Size of output. This could be smaller than GetPredictOutputSize() but could never be larger than GetPredictOutputSize().

Definition at line 447 of file predict.cc.

◆ Predict() [2/2]

std::size_t Predict ( const Model model,
const float *  input,
std::size_t  num_row,
float *  output,
int  nthread,
bool  pred_transform 
)

Predict with a 2D dense array.

Parameters
modelThe 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 GetPredictOutputSize() to get the amount of buffer you should allocate for this parameter.
nthreadnumber of CPU threads to use. Set <= 0 to use all CPU cores.
pred_transformAfter computing the prediction score, whether to transform it.
Returns
Size of output. This could be smaller than GetPredictOutputSize() but could never be larger than GetPredictOutputSize().

Definition at line 468 of file predict.cc.