15 const uint32_t* col_ind,
16 const size_t* row_ptr,
17 size_t num_row,
size_t num_col,
32 delete static_cast<CSRBatch*
>(handle);
37 size_t num_row,
size_t num_col,
58 size_t* out_num_col) {
76 predictor->
Load(library_path);
88 size_t* out_result_size) {
93 *out_result_size = predictor_->
PredictBatch(batch_, nthread, verbose,
94 (pred_margin != 0), out_result);
97 *out_result_size = predictor_->
PredictBatch(batch_, nthread, verbose,
98 (pred_margin != 0), out_result);
Load prediction function exported as a shared library.
void * DenseBatchHandle
handle to batch of dense data rows
void * CSRBatchHandle
handle to batch of sparse data rows
const uint32_t * col_ind
feature indices
size_t PredictBatch(const CSRBatch *batch, int nthread, int verbose, bool pred_margin, float *out_result) const
make predictions on a batch of data rows
#define API_BEGIN()
macro to guard beginning and end section of all functions
int TreelitePredictorPredictBatch(PredictorHandle handle, void *batch, int batch_sparse, int nthread, int verbose, int pred_margin, float *out_result, size_t *out_result_size)
make predictions on a batch of data rows
size_t QueryResultSize(const CSRBatch *batch) const
Given a batch of data rows, query the necessary size of array to hold predictions for all data points...
C API of treelite, used for interfacing with other languages This header is used exclusively by the r...
int TreelitePredictorQueryResultSize(PredictorHandle handle, void *batch, int batch_sparse, size_t *out)
Given a batch of data rows, query the necessary size of array to hold predictions for all data points...
size_t QueryNumOutputGroup() const
Get the number of output groups in the loaded model The number is 1 for most tasks; it is greater tha...
int TreelitePredictorLoad(const char *library_path, PredictorHandle *out)
load prediction code into memory. This function assumes that the prediction code has been already com...
int TreeliteBatchGetDimension(void *handle, int batch_sparse, size_t *out_num_row, size_t *out_num_col)
get dimensions of a batch
sparse batch in Compressed Sparse Row (CSR) format
const size_t * row_ptr
pointer to row headers; length of [num_row] + 1
void Load(const char *name)
load the prediction function from dynamic shared library.
const float * data
feature values
Error handling for C API.
int TreeliteAssembleSparseBatch(const float *data, const uint32_t *col_ind, const size_t *row_ptr, size_t num_row, size_t num_col, CSRBatchHandle *out)
assemble a sparse batch
float missing_value
value representing the missing value (usually nan)
int TreeliteDeleteDenseBatch(DenseBatchHandle handle)
delete a dense batch from memory
int TreeliteDeleteSparseBatch(CSRBatchHandle handle)
delete a sparse batch from memory
int TreeliteAssembleDenseBatch(const float *data, float missing_value, size_t num_row, size_t num_col, DenseBatchHandle *out)
assemble a dense batch
void * PredictorHandle
handle to predictor class
const float * data
feature values
size_t num_row
number of rows
int TreelitePredictorQueryNumOutputGroup(PredictorHandle handle, size_t *out)
Get the number of output groups in the loaded model The number is 1 for most tasks; it is greater tha...
predictor class: wrapper for optimized prediction code
int TreelitePredictorFree(PredictorHandle handle)
delete predictor from memory
size_t num_row
number of rows
size_t num_col
number of columns (i.e. # of features used)
#define API_END()
every function starts with API_BEGIN(); and finishes with API_END() or API_END_HANDLE_ERROR ...
size_t num_col
number of columns (i.e. # of features used)