xgboost/tests/cpp/linear/test_linear.cu
Jiaming Yuan 0012f2ef93
Upgrade clang-tidy on CI. (#5469)
* Correct all clang-tidy errors.
* Upgrade clang-tidy to 10 on CI.

Co-authored-by: Hyunsu Cho <chohyu01@cs.washington.edu>
2020-04-05 04:42:29 +08:00

39 lines
1.1 KiB
Plaintext

// Copyright by Contributors
#include <xgboost/linear_updater.h>
#include <xgboost/gbm.h>
#include "../helpers.h"
#include "test_json_io.h"
#include "../../../src/gbm/gblinear_model.h"
namespace xgboost {
TEST(Linear, GPUCoordinate) {
size_t constexpr kRows = 10;
size_t constexpr kCols = 10;
auto mat = xgboost::RandomDataGenerator(kRows, kCols, 0).GenerateDMatix();
auto lparam = CreateEmptyGenericParam(GPUIDX);
LearnerModelParam mparam;
mparam.num_feature = kCols;
mparam.num_output_group = 1;
mparam.base_score = 0.5;
auto updater = std::unique_ptr<xgboost::LinearUpdater>(
xgboost::LinearUpdater::Create("gpu_coord_descent", &lparam));
updater->Configure({{"eta", "1."}});
xgboost::HostDeviceVector<xgboost::GradientPair> gpair(
mat->Info().num_row_, xgboost::GradientPair(-5, 1.0));
xgboost::gbm::GBLinearModel model{&mparam};
model.LazyInitModel();
updater->Update(&gpair, mat.get(), &model, gpair.Size());
ASSERT_EQ(model.Bias()[0], 5.0f);
}
TEST(GPUCoordinate, JsonIO) {
TestUpdaterJsonIO("gpu_coord_descent");
}
} // namespace xgboost