@@ -1,5 +1,5 @@
|
||||
/*!
|
||||
* Copyright 2014-2022 by XGBoost Contributors
|
||||
/**
|
||||
* Copyright 2014-2023, XGBoost Contributors
|
||||
* \file gblinear.cc
|
||||
* \brief Implementation of Linear booster, with L1/L2 regularization: Elastic Net
|
||||
* the update rule is parallel coordinate descent (shotgun)
|
||||
@@ -26,9 +26,9 @@
|
||||
#include "../common/timer.h"
|
||||
#include "../common/common.h"
|
||||
#include "../common/threading_utils.h"
|
||||
#include "../common/error_msg.h"
|
||||
|
||||
namespace xgboost {
|
||||
namespace gbm {
|
||||
namespace xgboost::gbm {
|
||||
|
||||
DMLC_REGISTRY_FILE_TAG(gblinear);
|
||||
|
||||
@@ -83,7 +83,16 @@ class GBLinear : public GradientBooster {
|
||||
}
|
||||
param_.UpdateAllowUnknown(cfg);
|
||||
param_.CheckGPUSupport();
|
||||
updater_.reset(LinearUpdater::Create(param_.updater, ctx_));
|
||||
if (param_.updater == "gpu_coord_descent") {
|
||||
LOG(WARNING) << error::DeprecatedFunc("gpu_coord_descent", "2.0.0",
|
||||
R"(device="cuda", updater="coord_descent")");
|
||||
}
|
||||
|
||||
if (param_.updater == "coord_descent" && ctx_->IsCUDA()) {
|
||||
updater_.reset(LinearUpdater::Create("gpu_coord_descent", ctx_));
|
||||
} else {
|
||||
updater_.reset(LinearUpdater::Create(param_.updater, ctx_));
|
||||
}
|
||||
updater_->Configure(cfg);
|
||||
monitor_.Init("GBLinear");
|
||||
}
|
||||
@@ -354,5 +363,4 @@ XGBOOST_REGISTER_GBM(GBLinear, "gblinear")
|
||||
.set_body([](LearnerModelParam const* booster_config, Context const* ctx) {
|
||||
return new GBLinear(booster_config, ctx);
|
||||
});
|
||||
} // namespace gbm
|
||||
} // namespace xgboost
|
||||
} // namespace xgboost::gbm
|
||||
|
||||
@@ -9,8 +9,7 @@
|
||||
#include "coordinate_common.h"
|
||||
#include "xgboost/json.h"
|
||||
|
||||
namespace xgboost {
|
||||
namespace linear {
|
||||
namespace xgboost::linear {
|
||||
|
||||
DMLC_REGISTER_PARAMETER(CoordinateParam);
|
||||
DMLC_REGISTRY_FILE_TAG(updater_coordinate);
|
||||
@@ -39,8 +38,9 @@ class CoordinateUpdater : public LinearUpdater {
|
||||
FromJson(config.at("linear_train_param"), &tparam_);
|
||||
FromJson(config.at("coordinate_param"), &cparam_);
|
||||
}
|
||||
void SaveConfig(Json* p_out) const override {
|
||||
auto& out = *p_out;
|
||||
void SaveConfig(Json *p_out) const override {
|
||||
LOG(DEBUG) << "Save config for CPU updater.";
|
||||
auto &out = *p_out;
|
||||
out["linear_train_param"] = ToJson(tparam_);
|
||||
out["coordinate_param"] = ToJson(cparam_);
|
||||
}
|
||||
@@ -99,5 +99,4 @@ class CoordinateUpdater : public LinearUpdater {
|
||||
XGBOOST_REGISTER_LINEAR_UPDATER(CoordinateUpdater, "coord_descent")
|
||||
.describe("Update linear model according to coordinate descent algorithm.")
|
||||
.set_body([]() { return new CoordinateUpdater(); });
|
||||
} // namespace linear
|
||||
} // namespace xgboost
|
||||
} // namespace xgboost::linear
|
||||
|
||||
@@ -15,8 +15,7 @@
|
||||
#include "../common/timer.h"
|
||||
#include "./param.h"
|
||||
|
||||
namespace xgboost {
|
||||
namespace linear {
|
||||
namespace xgboost::linear {
|
||||
|
||||
DMLC_REGISTRY_FILE_TAG(updater_gpu_coordinate);
|
||||
|
||||
@@ -29,7 +28,7 @@ DMLC_REGISTRY_FILE_TAG(updater_gpu_coordinate);
|
||||
class GPUCoordinateUpdater : public LinearUpdater { // NOLINT
|
||||
public:
|
||||
// set training parameter
|
||||
void Configure(Args const& args) override {
|
||||
void Configure(Args const &args) override {
|
||||
tparam_.UpdateAllowUnknown(args);
|
||||
coord_param_.UpdateAllowUnknown(args);
|
||||
selector_.reset(FeatureSelector::Create(tparam_.feature_selector));
|
||||
@@ -41,8 +40,9 @@ class GPUCoordinateUpdater : public LinearUpdater { // NOLINT
|
||||
FromJson(config.at("linear_train_param"), &tparam_);
|
||||
FromJson(config.at("coordinate_param"), &coord_param_);
|
||||
}
|
||||
void SaveConfig(Json* p_out) const override {
|
||||
auto& out = *p_out;
|
||||
void SaveConfig(Json *p_out) const override {
|
||||
LOG(DEBUG) << "Save config for GPU updater.";
|
||||
auto &out = *p_out;
|
||||
out["linear_train_param"] = ToJson(tparam_);
|
||||
out["coordinate_param"] = ToJson(coord_param_);
|
||||
}
|
||||
@@ -101,10 +101,9 @@ class GPUCoordinateUpdater : public LinearUpdater { // NOLINT
|
||||
monitor_.Stop("LazyInitDevice");
|
||||
|
||||
monitor_.Start("UpdateGpair");
|
||||
auto &in_gpair_host = in_gpair->ConstHostVector();
|
||||
// Update gpair
|
||||
if (ctx_->gpu_id >= 0) {
|
||||
this->UpdateGpair(in_gpair_host);
|
||||
this->UpdateGpair(in_gpair->ConstHostVector());
|
||||
}
|
||||
monitor_.Stop("UpdateGpair");
|
||||
|
||||
@@ -249,5 +248,4 @@ XGBOOST_REGISTER_LINEAR_UPDATER(GPUCoordinateUpdater, "gpu_coord_descent")
|
||||
"Update linear model according to coordinate descent algorithm. GPU "
|
||||
"accelerated.")
|
||||
.set_body([]() { return new GPUCoordinateUpdater(); });
|
||||
} // namespace linear
|
||||
} // namespace xgboost
|
||||
} // namespace xgboost::linear
|
||||
|
||||
Reference in New Issue
Block a user