Support host data in proxy DMatrix. (#7087)

This commit is contained in:
Jiaming Yuan
2021-07-08 11:35:48 +08:00
committed by GitHub
parent 5d7cdf2e36
commit 84d359efb8
9 changed files with 188 additions and 30 deletions

29
src/data/proxy_dmatrix.cc Normal file
View File

@@ -0,0 +1,29 @@
/*!
* Copyright 2021 by Contributors
* \file proxy_dmatrix.cc
*/
#include "proxy_dmatrix.h"
namespace xgboost {
namespace data {
void DMatrixProxy::SetArrayData(char const *c_interface) {
std::shared_ptr<ArrayAdapter> adapter{
new ArrayAdapter(StringView{c_interface})};
this->batch_ = adapter;
this->Info().num_col_ = adapter->NumColumns();
this->Info().num_row_ = adapter->NumRows();
}
void DMatrixProxy::SetCSRData(char const *c_indptr, char const *c_indices,
char const *c_values, bst_feature_t n_features, bool on_host) {
CHECK(on_host) << "Not implemented on device.";
std::shared_ptr<CSRArrayAdapter> adapter{
new CSRArrayAdapter(StringView{c_indptr}, StringView{c_indices},
StringView{c_values}, n_features)};
this->batch_ = adapter;
this->Info().num_col_ = adapter->NumColumns();
this->Info().num_row_ = adapter->NumRows();
}
} // namespace data
} // namespace xgboost