8 #include <dmlc/thread_local.h> 23 using TreeliteAPIThreadLocalStore
24 = dmlc::ThreadLocalStore<TreeliteAPIThreadLocalEntry>;
29 registry->Register(callback);
34 const char* path,
const char* format,
const char* data_type,
int nthread,
int verbose,
37 std::unique_ptr<DMatrix> mat = CSRDMatrix::Create(path, format, data_type, nthread, verbose);
43 const void* data,
const char* data_type_str,
const uint32_t* col_ind,
const size_t* row_ptr,
47 std::unique_ptr<DMatrix> matrix
48 = CSRDMatrix::Create(data_type, data, col_ind, row_ptr, num_row, num_col);
54 const void* data,
const char* data_type_str,
size_t num_row,
size_t num_col,
58 std::unique_ptr<DMatrix> matrix
59 = DenseDMatrix::Create(data_type, data, missing_value, num_row, num_col);
70 *out_num_row = dmat->GetNumRow();
71 *out_num_col = dmat->GetNumCol();
72 *out_nelem = dmat->GetNumElem();
78 delete static_cast<DMatrix*
>(handle);
#define API_BEGIN()
macro to guard beginning and end section of all functions
int TreeliteDMatrixFree(DMatrixHandle handle)
delete DMatrix from memory
int TreeliteDMatrixCreateFromCSR(const void *data, const char *data_type_str, const uint32_t *col_ind, const size_t *row_ptr, size_t num_row, size_t num_col, DMatrixHandle *out)
create DMatrix from a (in-memory) CSR matrix
Input data structure of Treelite.
int TreeliteDMatrixCreateFromFile(const char *path, const char *format, const char *data_type, int nthread, int verbose, DMatrixHandle *out)
create a sparse DMatrix from a file
logging facility for Treelite
TypeInfo
Types used by thresholds and leaf outputs.
void * DMatrixHandle
handle to a data matrix
entry to to easily hold returning information
Error handling for C API.
int TreeliteRegisterLogCallback(void(*callback)(const char *))
register callback function for LOG(INFO) messages – helpful messages that are not errors...
TypeInfo GetTypeInfoByName(const std::string &str)
conversion table from string to TypeInfo, defined in tables.cc
C API of Treelite, used for interfacing with other languages This header is used by both the runtime ...
int TreeliteDMatrixGetDimension(DMatrixHandle handle, size_t *out_num_row, size_t *out_num_col, size_t *out_nelem)
get dimensions of a DMatrix
std::string ret_str
result holder for returning string
int TreeliteDMatrixCreateFromMat(const void *data, const char *data_type_str, size_t num_row, size_t num_col, const void *missing_value, DMatrixHandle *out)
create DMatrix from a (in-memory) dense matrix
#define API_END()
every function starts with API_BEGIN(); and finishes with API_END() or API_END_HANDLE_ERROR ...