Replaced std::vector with HostDeviceVector in MetaInfo and SparsePage. (#3446)
* Replaced std::vector with HostDeviceVector in MetaInfo and SparsePage. - added distributions to HostDeviceVector - using HostDeviceVector for labels, weights and base margings in MetaInfo - using HostDeviceVector for offset and data in SparsePage - other necessary refactoring * Added const version of HostDeviceVector API calls. - const versions added to calls that can trigger data transfers, e.g. DevicePointer() - updated the code that uses HostDeviceVector - objective functions now accept const HostDeviceVector<bst_float>& for predictions * Updated src/linear/updater_gpu_coordinate.cu. * Added read-only state for HostDeviceVector sync. - this means no copies are performed if both host and devices access the HostDeviceVector read-only * Fixed linter and test errors. - updated the lz4 plugin - added ConstDeviceSpan to HostDeviceVector - using device % dh::NVisibleDevices() for the physical device number, e.g. in calls to cudaSetDevice() * Fixed explicit template instantiation errors for HostDeviceVector. - replaced HostDeviceVector<unsigned int> with HostDeviceVector<int> * Fixed HostDeviceVector tests that require multiple GPUs. - added a mock set device handler; when set, it is called instead of cudaSetDevice()
This commit is contained in:
committed by
Rory Mitchell
parent
58d783df16
commit
72cd1517d6
@@ -49,9 +49,8 @@ void _CheckObjFunction(xgboost::ObjFunction * obj,
|
||||
std::vector<xgboost::bst_float> out_grad,
|
||||
std::vector<xgboost::bst_float> out_hess) {
|
||||
xgboost::HostDeviceVector<xgboost::bst_float> in_preds(preds);
|
||||
|
||||
xgboost::HostDeviceVector<xgboost::GradientPair> out_gpair;
|
||||
obj->GetGradient(&in_preds, info, 1, &out_gpair);
|
||||
obj->GetGradient(in_preds, info, 1, &out_gpair);
|
||||
std::vector<xgboost::GradientPair>& gpair = out_gpair.HostVector();
|
||||
|
||||
ASSERT_EQ(gpair.size(), in_preds.Size());
|
||||
@@ -73,8 +72,8 @@ void CheckObjFunction(xgboost::ObjFunction * obj,
|
||||
std::vector<xgboost::bst_float> out_hess) {
|
||||
xgboost::MetaInfo info;
|
||||
info.num_row_ = labels.size();
|
||||
info.labels_ = labels;
|
||||
info.weights_ = weights;
|
||||
info.labels_.HostVector() = labels;
|
||||
info.weights_.HostVector() = weights;
|
||||
|
||||
_CheckObjFunction(obj, preds, labels, weights, info, out_grad, out_hess);
|
||||
}
|
||||
@@ -88,8 +87,8 @@ void CheckRankingObjFunction(xgboost::ObjFunction * obj,
|
||||
std::vector<xgboost::bst_float> out_hess) {
|
||||
xgboost::MetaInfo info;
|
||||
info.num_row_ = labels.size();
|
||||
info.labels_ = labels;
|
||||
info.weights_ = weights;
|
||||
info.labels_.HostVector() = labels;
|
||||
info.weights_.HostVector() = weights;
|
||||
info.group_ptr_ = groups;
|
||||
|
||||
_CheckObjFunction(obj, preds, labels, weights, info, out_grad, out_hess);
|
||||
@@ -102,8 +101,8 @@ xgboost::bst_float GetMetricEval(xgboost::Metric * metric,
|
||||
std::vector<xgboost::bst_float> weights) {
|
||||
xgboost::MetaInfo info;
|
||||
info.num_row_ = labels.size();
|
||||
info.labels_ = labels;
|
||||
info.weights_ = weights;
|
||||
info.labels_.HostVector() = labels;
|
||||
info.weights_.HostVector() = weights;
|
||||
return metric->Eval(preds, info, false);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user