Support dmatrix construction from cupy array (#5206)

This commit is contained in:
Rory Mitchell
2020-01-22 13:15:27 +13:00
committed by GitHub
parent 2a071cebc5
commit 9c56480c61
19 changed files with 522 additions and 158 deletions

View File

@@ -7,14 +7,27 @@
#include "../data/device_adapter.cuh"
namespace xgboost {
XGB_DLL int XGDMatrixCreateFromArrayInterfaces(char const* c_json_strs,
bst_int has_missing,
bst_float missing,
DMatrixHandle* out) {
XGB_DLL int XGDMatrixCreateFromArrayInterfaceColumns(char const* c_json_strs,
bst_float missing,
int nthread,
DMatrixHandle* out) {
API_BEGIN();
std::string json_str{c_json_strs};
data::CudfAdapter adapter(json_str);
*out = new std::shared_ptr<DMatrix>(DMatrix::Create(&adapter, missing, 1));
*out =
new std::shared_ptr<DMatrix>(DMatrix::Create(&adapter, missing, nthread));
API_END();
}
XGB_DLL int XGDMatrixCreateFromArrayInterface(char const* c_json_strs,
bst_float missing, int nthread,
DMatrixHandle* out) {
API_BEGIN();
std::string json_str{c_json_strs};
data::CupyAdapter adapter(json_str);
*out =
new std::shared_ptr<DMatrix>(DMatrix::Create(&adapter, missing, nthread));
API_END();
}
} // namespace xgboost