Skip to content

Commit

Permalink
Type fix for WebAssembly: use size_t instead of bst_ulong for ncol in…
Browse files Browse the repository at this point in the history
… CSR conversion in c_api.
  • Loading branch information
yzhliu committed Oct 20, 2022
1 parent 28a466a commit c4d2407
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions include/xgboost/c_api.h
Expand Up @@ -168,7 +168,7 @@ XGB_DLL int XGDMatrixCreateFromCSREx(const size_t* indptr,
* \return 0 when success, -1 when failure happens
*/
XGB_DLL int XGDMatrixCreateFromCSR(char const *indptr, char const *indices, char const *data,
bst_ulong ncol, char const *config, DMatrixHandle *out);
size_t ncol, char const *config, DMatrixHandle *out);

/*!
* \brief Create a matrix from dense array.
Expand Down Expand Up @@ -1094,7 +1094,7 @@ XGB_DLL int XGBoosterPredictFromDense(BoosterHandle handle, char const *values,
* \return 0 when success, -1 when failure happens
*/
XGB_DLL int XGBoosterPredictFromCSR(BoosterHandle handle, char const *indptr, char const *indices,
char const *values, bst_ulong ncol, char const *config,
char const *values, size_t ncol, char const *config,
DMatrixHandle m, bst_ulong const **out_shape,
bst_ulong *out_dim, const float **out_result);

Expand Down
6 changes: 3 additions & 3 deletions src/c_api/c_api.cc
Expand Up @@ -399,7 +399,7 @@ XGB_DLL int XGDMatrixCreateFromCSREx(const size_t* indptr,

XGB_DLL int XGDMatrixCreateFromCSR(char const *indptr,
char const *indices, char const *data,
xgboost::bst_ulong ncol,
size_t ncol,
char const* c_json_config,
DMatrixHandle* out) {
API_BEGIN();
Expand Down Expand Up @@ -1022,7 +1022,7 @@ XGB_DLL int XGBoosterPredictFromDense(BoosterHandle handle, char const *array_in
}

XGB_DLL int XGBoosterPredictFromCSR(BoosterHandle handle, char const *indptr, char const *indices,
char const *data, xgboost::bst_ulong cols,
char const *data, size_t cols,
char const *c_json_config, DMatrixHandle m,
xgboost::bst_ulong const **out_shape,
xgboost::bst_ulong *out_dim, const float **out_result) {
Expand All @@ -1037,7 +1037,7 @@ XGB_DLL int XGBoosterPredictFromCSR(BoosterHandle handle, char const *indptr, ch
auto proxy = dynamic_cast<data::DMatrixProxy *>(p_m.get());
CHECK(proxy) << "Invalid input type for inplace predict.";
xgboost_CHECK_C_ARG_PTR(indptr);
proxy->SetCSRData(indptr, indices, data, cols, true);
proxy->SetCSRData(indptr, indices, data, static_cast<bst_feature_t>(cols), true);
auto *learner = static_cast<xgboost::Learner *>(handle);
InplacePredictImpl(p_m, c_json_config, learner, out_shape, out_dim, out_result);
API_END();
Expand Down

0 comments on commit c4d2407

Please sign in to comment.