Unify test helpers for creating ctx. (#9274)
This commit is contained in:
@@ -12,19 +12,19 @@
|
||||
|
||||
namespace xgboost {
|
||||
inline void TestUpdaterJsonIO(std::string updater_str) {
|
||||
auto runtime = xgboost::CreateEmptyGenericParam(GPUIDX);
|
||||
Context ctx{MakeCUDACtx(GPUIDX)};
|
||||
Json config_0 {Object() };
|
||||
|
||||
{
|
||||
auto updater = std::unique_ptr<xgboost::LinearUpdater>(
|
||||
xgboost::LinearUpdater::Create(updater_str, &runtime));
|
||||
auto updater =
|
||||
std::unique_ptr<xgboost::LinearUpdater>(xgboost::LinearUpdater::Create(updater_str, &ctx));
|
||||
updater->Configure({{"eta", std::to_string(3.14)}});
|
||||
updater->SaveConfig(&config_0);
|
||||
}
|
||||
|
||||
{
|
||||
auto updater = std::unique_ptr<xgboost::LinearUpdater>(
|
||||
xgboost::LinearUpdater::Create(updater_str, &runtime));
|
||||
auto updater =
|
||||
std::unique_ptr<xgboost::LinearUpdater>(xgboost::LinearUpdater::Create(updater_str, &ctx));
|
||||
updater->LoadConfig(config_0);
|
||||
Json config_1 { Object() };
|
||||
updater->SaveConfig(&config_1);
|
||||
|
||||
@@ -17,7 +17,7 @@ TEST(Linear, Shotgun) {
|
||||
|
||||
auto p_fmat = xgboost::RandomDataGenerator(kRows, kCols, 0).GenerateDMatrix();
|
||||
|
||||
auto ctx = xgboost::CreateEmptyGenericParam(GPUIDX);
|
||||
auto ctx = MakeCUDACtx(GPUIDX);
|
||||
LearnerModelParam mparam{MakeMP(kCols, .5, 1)};
|
||||
|
||||
{
|
||||
@@ -49,7 +49,7 @@ TEST(Linear, coordinate) {
|
||||
|
||||
auto p_fmat = xgboost::RandomDataGenerator(kRows, kCols, 0).GenerateDMatrix();
|
||||
|
||||
auto ctx = xgboost::CreateEmptyGenericParam(GPUIDX);
|
||||
auto ctx = MakeCUDACtx(GPUIDX);
|
||||
LearnerModelParam mparam{MakeMP(kCols, .5, 1)};
|
||||
|
||||
auto updater = std::unique_ptr<xgboost::LinearUpdater>(
|
||||
|
||||
@@ -13,7 +13,7 @@ TEST(Linear, GPUCoordinate) {
|
||||
size_t constexpr kCols = 10;
|
||||
|
||||
auto mat = xgboost::RandomDataGenerator(kRows, kCols, 0).GenerateDMatrix();
|
||||
auto ctx = CreateEmptyGenericParam(GPUIDX);
|
||||
auto ctx = MakeCUDACtx(0);
|
||||
|
||||
LearnerModelParam mparam{MakeMP(kCols, .5, 1)};
|
||||
auto updater = std::unique_ptr<xgboost::LinearUpdater>(
|
||||
|
||||
Reference in New Issue
Block a user