treelite
c_api_runtime.h
Go to the documentation of this file.
1 
9 /* Note: Make sure to use slash-asterisk form of comments in this file
10  (like this one). Do not use double-slash (//). */
11 
12 #ifndef TREELITE_C_API_RUNTIME_H_
13 #define TREELITE_C_API_RUNTIME_H_
14 
15 #include "c_api_common.h"
16 
23 typedef void* PredictorHandle;
25 typedef void* CSRBatchHandle;
27 typedef void* DenseBatchHandle;
45 TREELITE_DLL int TreeliteAssembleSparseBatch(const float* data,
46  const uint32_t* col_ind,
47  const size_t* row_ptr,
48  size_t num_row, size_t num_col,
49  CSRBatchHandle* out);
55 TREELITE_DLL int TreeliteDeleteSparseBatch(CSRBatchHandle handle);
65 TREELITE_DLL int TreeliteAssembleDenseBatch(const float* data,
66  float missing_value,
67  size_t num_row, size_t num_col,
68  DenseBatchHandle* out);
74 TREELITE_DLL int TreeliteDeleteDenseBatch(DenseBatchHandle handle);
75 
84 TREELITE_DLL int TreeliteBatchGetDimension(void* handle,
85  int batch_sparse,
86  size_t* out_num_row,
87  size_t* out_num_col);
88 
101 TREELITE_DLL int TreelitePredictorLoad(const char* library_path,
102  int num_worker_thread,
103  int include_master_thread,
104  PredictorHandle* out);
122 TREELITE_DLL int TreelitePredictorPredictBatch(PredictorHandle handle,
123  void* batch,
124  int batch_sparse,
125  int verbose,
126  int pred_margin,
127  float* out_result,
128  size_t* out_result_size);
129 
139 TREELITE_DLL int TreelitePredictorQueryResultSize(PredictorHandle handle,
140  void* batch,
141  int batch_sparse,
142  size_t* out);
152  size_t* out);
158 TREELITE_DLL int TreelitePredictorFree(PredictorHandle handle);
161 #endif // TREELITE_C_API_RUNTIME_H_
void * DenseBatchHandle
handle to batch of dense data rows
Definition: c_api_runtime.h:27
void * CSRBatchHandle
handle to batch of sparse data rows
Definition: c_api_runtime.h:25
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...
int TreelitePredictorLoad(const char *library_path, int num_worker_thread, int include_master_thread, PredictorHandle *out)
load prediction code into memory. This function assumes that the prediction code has been already com...
int TreelitePredictorPredictBatch(PredictorHandle handle, void *batch, int batch_sparse, int verbose, int pred_margin, float *out_result, size_t *out_result_size)
Make predictions on a batch of data rows (synchronously). This function internally divides the worklo...
int TreeliteBatchGetDimension(void *handle, int batch_sparse, size_t *out_num_row, size_t *out_num_col)
get dimensions of a batch
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
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
C API of treelite, used for interfacing with other languages This header is used by both the runtime ...
void * PredictorHandle
handle to predictor class
Definition: c_api_runtime.h:23
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...
int TreelitePredictorFree(PredictorHandle handle)
delete predictor from memory