* Only define `gpu_id` and `n_gpus` in `LearnerTrainParam` * Pass LearnerTrainParam through XGBoost vid factory method. * Disable all GPU usage when GPU related parameters are not specified (fixes XGBoost choosing GPU over aggressively). * Test learner train param io. * Fix gpu pickling.
20 lines
553 B
C++
20 lines
553 B
C++
// Copyright by Contributors
|
|
#include <gtest/gtest.h>
|
|
#include <xgboost/objective.h>
|
|
#include <xgboost/generic_parameters.h>
|
|
|
|
#include "../helpers.h"
|
|
|
|
TEST(Objective, UnknownFunction) {
|
|
xgboost::ObjFunction* obj = nullptr;
|
|
xgboost::LearnerTrainParam tparam;
|
|
std::vector<std::pair<std::string, std::string>> args;
|
|
tparam.InitAllowUnknown(args);
|
|
|
|
EXPECT_ANY_THROW(obj = xgboost::ObjFunction::Create("unknown_name", &tparam));
|
|
EXPECT_NO_THROW(obj = xgboost::ObjFunction::Create("reg:squarederror", &tparam));
|
|
if (obj) {
|
|
delete obj;
|
|
}
|
|
}
|