Implement cudf construction with adapters. (#5189)

This commit is contained in:
Rory Mitchell
2020-01-09 20:23:06 +13:00
committed by GitHub
parent 9559f81377
commit 87ebfc1315
14 changed files with 705 additions and 34 deletions

View File

@@ -204,15 +204,14 @@ int XGDMatrixCreateFromDataIter(
API_END();
}
#ifndef XGBOOST_USE_CUDA
XGB_DLL int XGDMatrixCreateFromArrayInterfaces(
char const* c_json_strs, bst_int has_missing, bst_float missing, DMatrixHandle* out) {
char const* c_json_strs, bst_int has_missing, bst_float missing, DMatrixHandle* out) {
API_BEGIN();
std::string json_str {c_json_strs};
std::unique_ptr<data::SimpleCSRSource> source (new data::SimpleCSRSource());
source->CopyFrom(json_str, has_missing, missing);
*out = new std::shared_ptr<DMatrix>(DMatrix::Create(std::move(source)));
LOG(FATAL) << "Xgboost not compiled with cuda";
API_END();
}
#endif
XGB_DLL int XGDMatrixCreateFromCSREx(const size_t* indptr,
const unsigned* indices,

20
src/c_api/c_api.cu Normal file
View File

@@ -0,0 +1,20 @@
// Copyright (c) 2014-2019 by Contributors
#include "xgboost/data.h"
#include "xgboost/c_api.h"
#include "c_api_error.h"
#include "../data/simple_csr_source.h"
#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) {
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));
API_END();
}
} // namespace xgboost