Rename and extract Context. (#8528)
* Rename `GenericParameter` to `Context`. * Rename header file to reflect the change. * Rename all references.
This commit is contained in:
@@ -16,8 +16,8 @@ namespace xgboost {
|
||||
namespace common {
|
||||
|
||||
TEST(Objective, DeclareUnifiedTest(AFTObjConfiguration)) {
|
||||
auto lparam = CreateEmptyGenericParam(GPUIDX);
|
||||
std::unique_ptr<ObjFunction> objective(ObjFunction::Create("survival:aft", &lparam));
|
||||
auto ctx = CreateEmptyGenericParam(GPUIDX);
|
||||
std::unique_ptr<ObjFunction> objective(ObjFunction::Create("survival:aft", &ctx));
|
||||
objective->Configure({ {"aft_loss_distribution", "logistic"},
|
||||
{"aft_loss_distribution_scale", "5"} });
|
||||
|
||||
@@ -77,8 +77,8 @@ static inline void CheckGPairOverGridPoints(
|
||||
}
|
||||
|
||||
TEST(Objective, DeclareUnifiedTest(AFTObjGPairUncensoredLabels)) {
|
||||
auto lparam = CreateEmptyGenericParam(GPUIDX);
|
||||
std::unique_ptr<ObjFunction> obj(ObjFunction::Create("survival:aft", &lparam));
|
||||
auto ctx = CreateEmptyGenericParam(GPUIDX);
|
||||
std::unique_ptr<ObjFunction> obj(ObjFunction::Create("survival:aft", &ctx));
|
||||
|
||||
CheckGPairOverGridPoints(obj.get(), 100.0f, 100.0f, "normal",
|
||||
{ -3.9120f, -3.4013f, -2.8905f, -2.3798f, -1.8691f, -1.3583f, -0.8476f, -0.3368f, 0.1739f,
|
||||
@@ -101,8 +101,8 @@ TEST(Objective, DeclareUnifiedTest(AFTObjGPairUncensoredLabels)) {
|
||||
}
|
||||
|
||||
TEST(Objective, DeclareUnifiedTest(AFTObjGPairLeftCensoredLabels)) {
|
||||
auto lparam = CreateEmptyGenericParam(GPUIDX);
|
||||
std::unique_ptr<ObjFunction> obj(ObjFunction::Create("survival:aft", &lparam));
|
||||
auto ctx = CreateEmptyGenericParam(GPUIDX);
|
||||
std::unique_ptr<ObjFunction> obj(ObjFunction::Create("survival:aft", &ctx));
|
||||
|
||||
CheckGPairOverGridPoints(obj.get(), 0.0f, 20.0f, "normal",
|
||||
{ 0.0285f, 0.0832f, 0.1951f, 0.3804f, 0.6403f, 0.9643f, 1.3379f, 1.7475f, 2.1828f, 2.6361f,
|
||||
@@ -122,8 +122,8 @@ TEST(Objective, DeclareUnifiedTest(AFTObjGPairLeftCensoredLabels)) {
|
||||
}
|
||||
|
||||
TEST(Objective, DeclareUnifiedTest(AFTObjGPairRightCensoredLabels)) {
|
||||
auto lparam = CreateEmptyGenericParam(GPUIDX);
|
||||
std::unique_ptr<ObjFunction> obj(ObjFunction::Create("survival:aft", &lparam));
|
||||
auto ctx = CreateEmptyGenericParam(GPUIDX);
|
||||
std::unique_ptr<ObjFunction> obj(ObjFunction::Create("survival:aft", &ctx));
|
||||
|
||||
CheckGPairOverGridPoints(obj.get(), 60.0f, std::numeric_limits<float>::infinity(), "normal",
|
||||
{ -3.6583f, -3.1815f, -2.7135f, -2.2577f, -1.8190f, -1.4044f, -1.0239f, -0.6905f, -0.4190f,
|
||||
@@ -146,8 +146,8 @@ TEST(Objective, DeclareUnifiedTest(AFTObjGPairRightCensoredLabels)) {
|
||||
}
|
||||
|
||||
TEST(Objective, DeclareUnifiedTest(AFTObjGPairIntervalCensoredLabels)) {
|
||||
auto lparam = CreateEmptyGenericParam(GPUIDX);
|
||||
std::unique_ptr<ObjFunction> obj(ObjFunction::Create("survival:aft", &lparam));
|
||||
auto ctx = CreateEmptyGenericParam(GPUIDX);
|
||||
std::unique_ptr<ObjFunction> obj(ObjFunction::Create("survival:aft", &ctx));
|
||||
|
||||
CheckGPairOverGridPoints(obj.get(), 16.0f, 200.0f, "normal",
|
||||
{ -2.4435f, -1.9965f, -1.5691f, -1.1679f, -0.7990f, -0.4649f, -0.1596f, 0.1336f, 0.4370f,
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
// Copyright by Contributors
|
||||
#include <xgboost/objective.h>
|
||||
#include <xgboost/generic_parameters.h>
|
||||
#include <xgboost/context.h>
|
||||
#include <limits>
|
||||
|
||||
#include "../helpers.h"
|
||||
|
||||
TEST(Objective, DeclareUnifiedTest(HingeObj)) {
|
||||
xgboost::GenericParameter tparam = xgboost::CreateEmptyGenericParam(GPUIDX);
|
||||
xgboost::Context ctx = xgboost::CreateEmptyGenericParam(GPUIDX);
|
||||
std::unique_ptr<xgboost::ObjFunction> obj {
|
||||
xgboost::ObjFunction::Create("binary:hinge", &tparam)
|
||||
xgboost::ObjFunction::Create("binary:hinge", &ctx)
|
||||
};
|
||||
|
||||
xgboost::bst_float eps = std::numeric_limits<xgboost::bst_float>::min();
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
* Copyright 2018-2019 XGBoost contributors
|
||||
*/
|
||||
#include <xgboost/objective.h>
|
||||
#include <xgboost/generic_parameters.h>
|
||||
#include <xgboost/context.h>
|
||||
#include "../../src/common/common.h"
|
||||
#include "../helpers.h"
|
||||
|
||||
namespace xgboost {
|
||||
|
||||
TEST(Objective, DeclareUnifiedTest(SoftmaxMultiClassObjGPair)) {
|
||||
GenericParameter lparam = CreateEmptyGenericParam(GPUIDX);
|
||||
Context ctx = CreateEmptyGenericParam(GPUIDX);
|
||||
std::vector<std::pair<std::string, std::string>> args {{"num_class", "3"}};
|
||||
std::unique_ptr<ObjFunction> obj {
|
||||
ObjFunction::Create("multi:softmax", &lparam)
|
||||
ObjFunction::Create("multi:softmax", &ctx)
|
||||
};
|
||||
|
||||
obj->Configure(args);
|
||||
@@ -36,11 +36,11 @@ TEST(Objective, DeclareUnifiedTest(SoftmaxMultiClassObjGPair)) {
|
||||
}
|
||||
|
||||
TEST(Objective, DeclareUnifiedTest(SoftmaxMultiClassBasic)) {
|
||||
auto lparam = CreateEmptyGenericParam(GPUIDX);
|
||||
auto ctx = CreateEmptyGenericParam(GPUIDX);
|
||||
std::vector<std::pair<std::string, std::string>> args{
|
||||
std::pair<std::string, std::string>("num_class", "3")};
|
||||
std::pair<std::string, std::string>("num_class", "3")};
|
||||
|
||||
std::unique_ptr<ObjFunction> obj { ObjFunction::Create("multi:softmax", &lparam) };
|
||||
std::unique_ptr<ObjFunction> obj{ObjFunction::Create("multi:softmax", &ctx)};
|
||||
obj->Configure(args);
|
||||
CheckConfigReload(obj, "multi:softmax");
|
||||
|
||||
@@ -57,12 +57,12 @@ TEST(Objective, DeclareUnifiedTest(SoftmaxMultiClassBasic)) {
|
||||
}
|
||||
|
||||
TEST(Objective, DeclareUnifiedTest(SoftprobMultiClassBasic)) {
|
||||
GenericParameter lparam = CreateEmptyGenericParam(GPUIDX);
|
||||
Context ctx = CreateEmptyGenericParam(GPUIDX);
|
||||
std::vector<std::pair<std::string, std::string>> args {
|
||||
std::pair<std::string, std::string>("num_class", "3")};
|
||||
|
||||
std::unique_ptr<ObjFunction> obj {
|
||||
ObjFunction::Create("multi:softprob", &lparam)
|
||||
ObjFunction::Create("multi:softprob", &ctx)
|
||||
};
|
||||
obj->Configure(args);
|
||||
CheckConfigReload(obj, "multi:softprob");
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
// Copyright by Contributors
|
||||
#include <gtest/gtest.h>
|
||||
#include <xgboost/context.h>
|
||||
#include <xgboost/objective.h>
|
||||
#include <xgboost/generic_parameters.h>
|
||||
|
||||
#include "../helpers.h"
|
||||
|
||||
TEST(Objective, UnknownFunction) {
|
||||
xgboost::ObjFunction* obj = nullptr;
|
||||
xgboost::GenericParameter tparam;
|
||||
xgboost::Context tparam;
|
||||
std::vector<std::pair<std::string, std::string>> args;
|
||||
tparam.UpdateAllowUnknown(args);
|
||||
|
||||
@@ -21,7 +21,7 @@ TEST(Objective, UnknownFunction) {
|
||||
namespace xgboost {
|
||||
TEST(Objective, PredTransform) {
|
||||
// Test that show PredTransform uses the same device with predictor.
|
||||
xgboost::GenericParameter tparam;
|
||||
xgboost::Context tparam;
|
||||
tparam.UpdateAllowUnknown(Args{{"gpu_id", "0"}});
|
||||
size_t n = 100;
|
||||
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
// Copyright by Contributors
|
||||
#include <xgboost/objective.h>
|
||||
#include <xgboost/generic_parameters.h>
|
||||
#include "../helpers.h"
|
||||
#include <xgboost/context.h>
|
||||
#include <xgboost/json.h>
|
||||
#include <xgboost/objective.h>
|
||||
|
||||
#include "../helpers.h"
|
||||
|
||||
namespace xgboost {
|
||||
|
||||
TEST(Objective, DeclareUnifiedTest(PairwiseRankingGPair)) {
|
||||
std::vector<std::pair<std::string, std::string>> args;
|
||||
xgboost::GenericParameter lparam = xgboost::CreateEmptyGenericParam(GPUIDX);
|
||||
xgboost::Context ctx = xgboost::CreateEmptyGenericParam(GPUIDX);
|
||||
|
||||
std::unique_ptr<xgboost::ObjFunction> obj {
|
||||
xgboost::ObjFunction::Create("rank:pairwise", &lparam)
|
||||
};
|
||||
std::unique_ptr<xgboost::ObjFunction> obj{xgboost::ObjFunction::Create("rank:pairwise", &ctx)};
|
||||
obj->Configure(args);
|
||||
CheckConfigReload(obj, "rank:pairwise");
|
||||
|
||||
@@ -37,12 +36,10 @@ TEST(Objective, DeclareUnifiedTest(PairwiseRankingGPair)) {
|
||||
}
|
||||
|
||||
TEST(Objective, DeclareUnifiedTest(NDCG_JsonIO)) {
|
||||
xgboost::GenericParameter tparam;
|
||||
tparam.UpdateAllowUnknown(Args{});
|
||||
xgboost::Context ctx;
|
||||
ctx.UpdateAllowUnknown(Args{});
|
||||
|
||||
std::unique_ptr<xgboost::ObjFunction> obj {
|
||||
xgboost::ObjFunction::Create("rank:ndcg", &tparam)
|
||||
};
|
||||
std::unique_ptr<xgboost::ObjFunction> obj{xgboost::ObjFunction::Create("rank:ndcg", &ctx)};
|
||||
|
||||
obj->Configure(Args{});
|
||||
Json j_obj {Object()};
|
||||
@@ -58,11 +55,9 @@ TEST(Objective, DeclareUnifiedTest(NDCG_JsonIO)) {
|
||||
|
||||
TEST(Objective, DeclareUnifiedTest(PairwiseRankingGPairSameLabels)) {
|
||||
std::vector<std::pair<std::string, std::string>> args;
|
||||
xgboost::GenericParameter lparam = xgboost::CreateEmptyGenericParam(GPUIDX);
|
||||
xgboost::Context ctx = xgboost::CreateEmptyGenericParam(GPUIDX);
|
||||
|
||||
std::unique_ptr<ObjFunction> obj {
|
||||
ObjFunction::Create("rank:pairwise", &lparam)
|
||||
};
|
||||
std::unique_ptr<ObjFunction> obj{ObjFunction::Create("rank:pairwise", &ctx)};
|
||||
obj->Configure(args);
|
||||
// No computation of gradient/hessian, as there is no diversity in labels
|
||||
CheckRankingObjFunction(obj,
|
||||
@@ -78,11 +73,9 @@ TEST(Objective, DeclareUnifiedTest(PairwiseRankingGPairSameLabels)) {
|
||||
|
||||
TEST(Objective, DeclareUnifiedTest(NDCGRankingGPair)) {
|
||||
std::vector<std::pair<std::string, std::string>> args;
|
||||
xgboost::GenericParameter lparam = xgboost::CreateEmptyGenericParam(GPUIDX);
|
||||
xgboost::Context ctx = xgboost::CreateEmptyGenericParam(GPUIDX);
|
||||
|
||||
std::unique_ptr<xgboost::ObjFunction> obj {
|
||||
xgboost::ObjFunction::Create("rank:ndcg", &lparam)
|
||||
};
|
||||
std::unique_ptr<xgboost::ObjFunction> obj{xgboost::ObjFunction::Create("rank:ndcg", &ctx)};
|
||||
obj->Configure(args);
|
||||
CheckConfigReload(obj, "rank:ndcg");
|
||||
|
||||
@@ -107,11 +100,9 @@ TEST(Objective, DeclareUnifiedTest(NDCGRankingGPair)) {
|
||||
|
||||
TEST(Objective, DeclareUnifiedTest(MAPRankingGPair)) {
|
||||
std::vector<std::pair<std::string, std::string>> args;
|
||||
xgboost::GenericParameter lparam = xgboost::CreateEmptyGenericParam(GPUIDX);
|
||||
xgboost::Context ctx = xgboost::CreateEmptyGenericParam(GPUIDX);
|
||||
|
||||
std::unique_ptr<xgboost::ObjFunction> obj {
|
||||
xgboost::ObjFunction::Create("rank:map", &lparam)
|
||||
};
|
||||
std::unique_ptr<xgboost::ObjFunction> obj{xgboost::ObjFunction::Create("rank:map", &ctx)};
|
||||
obj->Configure(args);
|
||||
CheckConfigReload(obj, "rank:map");
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Copyright 2017-2022 XGBoost contributors
|
||||
*/
|
||||
#include <gtest/gtest.h>
|
||||
#include <xgboost/generic_parameters.h>
|
||||
#include <xgboost/context.h>
|
||||
#include <xgboost/json.h>
|
||||
#include <xgboost/objective.h>
|
||||
|
||||
@@ -12,12 +12,10 @@
|
||||
namespace xgboost {
|
||||
|
||||
TEST(Objective, DeclareUnifiedTest(LinearRegressionGPair)) {
|
||||
GenericParameter tparam = CreateEmptyGenericParam(GPUIDX);
|
||||
Context ctx = CreateEmptyGenericParam(GPUIDX);
|
||||
std::vector<std::pair<std::string, std::string>> args;
|
||||
|
||||
std::unique_ptr<ObjFunction> obj {
|
||||
ObjFunction::Create("reg:squarederror", &tparam)
|
||||
};
|
||||
std::unique_ptr<ObjFunction> obj{ObjFunction::Create("reg:squarederror", &ctx)};
|
||||
|
||||
obj->Configure(args);
|
||||
CheckObjFunction(obj,
|
||||
@@ -36,10 +34,10 @@ TEST(Objective, DeclareUnifiedTest(LinearRegressionGPair)) {
|
||||
}
|
||||
|
||||
TEST(Objective, DeclareUnifiedTest(SquaredLog)) {
|
||||
GenericParameter tparam = CreateEmptyGenericParam(GPUIDX);
|
||||
Context ctx = CreateEmptyGenericParam(GPUIDX);
|
||||
std::vector<std::pair<std::string, std::string>> args;
|
||||
|
||||
std::unique_ptr<ObjFunction> obj { ObjFunction::Create("reg:squaredlogerror", &tparam) };
|
||||
std::unique_ptr<ObjFunction> obj{ObjFunction::Create("reg:squaredlogerror", &ctx)};
|
||||
obj->Configure(args);
|
||||
CheckConfigReload(obj, "reg:squaredlogerror");
|
||||
|
||||
@@ -59,10 +57,10 @@ TEST(Objective, DeclareUnifiedTest(SquaredLog)) {
|
||||
}
|
||||
|
||||
TEST(Objective, DeclareUnifiedTest(PseudoHuber)) {
|
||||
GenericParameter tparam = CreateEmptyGenericParam(GPUIDX);
|
||||
Context ctx = CreateEmptyGenericParam(GPUIDX);
|
||||
Args args;
|
||||
|
||||
std::unique_ptr<ObjFunction> obj{ObjFunction::Create("reg:pseudohubererror", &tparam)};
|
||||
std::unique_ptr<ObjFunction> obj{ObjFunction::Create("reg:pseudohubererror", &ctx)};
|
||||
obj->Configure(args);
|
||||
CheckConfigReload(obj, "reg:pseudohubererror");
|
||||
|
||||
@@ -88,9 +86,9 @@ TEST(Objective, DeclareUnifiedTest(PseudoHuber)) {
|
||||
}
|
||||
|
||||
TEST(Objective, DeclareUnifiedTest(LogisticRegressionGPair)) {
|
||||
GenericParameter tparam = CreateEmptyGenericParam(GPUIDX);
|
||||
Context ctx = CreateEmptyGenericParam(GPUIDX);
|
||||
std::vector<std::pair<std::string, std::string>> args;
|
||||
std::unique_ptr<ObjFunction> obj { ObjFunction::Create("reg:logistic", &tparam) };
|
||||
std::unique_ptr<ObjFunction> obj{ObjFunction::Create("reg:logistic", &ctx)};
|
||||
|
||||
obj->Configure(args);
|
||||
CheckConfigReload(obj, "reg:logistic");
|
||||
@@ -104,11 +102,9 @@ TEST(Objective, DeclareUnifiedTest(LogisticRegressionGPair)) {
|
||||
}
|
||||
|
||||
TEST(Objective, DeclareUnifiedTest(LogisticRegressionBasic)) {
|
||||
GenericParameter lparam = CreateEmptyGenericParam(GPUIDX);
|
||||
Context ctx = CreateEmptyGenericParam(GPUIDX);
|
||||
std::vector<std::pair<std::string, std::string>> args;
|
||||
std::unique_ptr<ObjFunction> obj {
|
||||
ObjFunction::Create("reg:logistic", &lparam)
|
||||
};
|
||||
std::unique_ptr<ObjFunction> obj{ObjFunction::Create("reg:logistic", &ctx)};
|
||||
|
||||
obj->Configure(args);
|
||||
CheckConfigReload(obj, "reg:logistic");
|
||||
@@ -135,10 +131,10 @@ TEST(Objective, DeclareUnifiedTest(LogisticRegressionBasic)) {
|
||||
}
|
||||
|
||||
TEST(Objective, DeclareUnifiedTest(LogisticRawGPair)) {
|
||||
GenericParameter lparam = CreateEmptyGenericParam(GPUIDX);
|
||||
Context ctx = CreateEmptyGenericParam(GPUIDX);
|
||||
std::vector<std::pair<std::string, std::string>> args;
|
||||
std::unique_ptr<ObjFunction> obj {
|
||||
ObjFunction::Create("binary:logitraw", &lparam)
|
||||
ObjFunction::Create("binary:logitraw", &ctx)
|
||||
};
|
||||
obj->Configure(args);
|
||||
|
||||
@@ -151,10 +147,10 @@ TEST(Objective, DeclareUnifiedTest(LogisticRawGPair)) {
|
||||
}
|
||||
|
||||
TEST(Objective, DeclareUnifiedTest(PoissonRegressionGPair)) {
|
||||
GenericParameter lparam = CreateEmptyGenericParam(GPUIDX);
|
||||
Context ctx = CreateEmptyGenericParam(GPUIDX);
|
||||
std::vector<std::pair<std::string, std::string>> args;
|
||||
std::unique_ptr<ObjFunction> obj {
|
||||
ObjFunction::Create("count:poisson", &lparam)
|
||||
ObjFunction::Create("count:poisson", &ctx)
|
||||
};
|
||||
|
||||
args.emplace_back(std::make_pair("max_delta_step", "0.1f"));
|
||||
@@ -175,10 +171,10 @@ TEST(Objective, DeclareUnifiedTest(PoissonRegressionGPair)) {
|
||||
}
|
||||
|
||||
TEST(Objective, DeclareUnifiedTest(PoissonRegressionBasic)) {
|
||||
GenericParameter lparam = CreateEmptyGenericParam(GPUIDX);
|
||||
Context ctx = CreateEmptyGenericParam(GPUIDX);
|
||||
std::vector<std::pair<std::string, std::string>> args;
|
||||
std::unique_ptr<ObjFunction> obj {
|
||||
ObjFunction::Create("count:poisson", &lparam)
|
||||
ObjFunction::Create("count:poisson", &ctx)
|
||||
};
|
||||
|
||||
obj->Configure(args);
|
||||
@@ -204,10 +200,10 @@ TEST(Objective, DeclareUnifiedTest(PoissonRegressionBasic)) {
|
||||
}
|
||||
|
||||
TEST(Objective, DeclareUnifiedTest(GammaRegressionGPair)) {
|
||||
GenericParameter lparam = CreateEmptyGenericParam(GPUIDX);
|
||||
Context ctx = CreateEmptyGenericParam(GPUIDX);
|
||||
std::vector<std::pair<std::string, std::string>> args;
|
||||
std::unique_ptr<ObjFunction> obj {
|
||||
ObjFunction::Create("reg:gamma", &lparam)
|
||||
ObjFunction::Create("reg:gamma", &ctx)
|
||||
};
|
||||
|
||||
obj->Configure(args);
|
||||
@@ -226,11 +222,9 @@ TEST(Objective, DeclareUnifiedTest(GammaRegressionGPair)) {
|
||||
}
|
||||
|
||||
TEST(Objective, DeclareUnifiedTest(GammaRegressionBasic)) {
|
||||
GenericParameter lparam = CreateEmptyGenericParam(GPUIDX);
|
||||
Context ctx = CreateEmptyGenericParam(GPUIDX);
|
||||
std::vector<std::pair<std::string, std::string>> args;
|
||||
std::unique_ptr<ObjFunction> obj {
|
||||
ObjFunction::Create("reg:gamma", &lparam)
|
||||
};
|
||||
std::unique_ptr<ObjFunction> obj{ObjFunction::Create("reg:gamma", &ctx)};
|
||||
|
||||
obj->Configure(args);
|
||||
CheckConfigReload(obj, "reg:gamma");
|
||||
@@ -257,11 +251,9 @@ TEST(Objective, DeclareUnifiedTest(GammaRegressionBasic)) {
|
||||
}
|
||||
|
||||
TEST(Objective, DeclareUnifiedTest(TweedieRegressionGPair)) {
|
||||
GenericParameter lparam = CreateEmptyGenericParam(GPUIDX);
|
||||
Context ctx = CreateEmptyGenericParam(GPUIDX);
|
||||
std::vector<std::pair<std::string, std::string>> args;
|
||||
std::unique_ptr<ObjFunction> obj {
|
||||
ObjFunction::Create("reg:tweedie", &lparam)
|
||||
};
|
||||
std::unique_ptr<ObjFunction> obj{ObjFunction::Create("reg:tweedie", &ctx)};
|
||||
|
||||
args.emplace_back(std::make_pair("tweedie_variance_power", "1.1f"));
|
||||
obj->Configure(args);
|
||||
@@ -283,10 +275,9 @@ TEST(Objective, DeclareUnifiedTest(TweedieRegressionGPair)) {
|
||||
|
||||
#if defined(__CUDACC__)
|
||||
TEST(Objective, CPU_vs_CUDA) {
|
||||
GenericParameter lparam = CreateEmptyGenericParam(GPUIDX);
|
||||
Context ctx = CreateEmptyGenericParam(GPUIDX);
|
||||
|
||||
ObjFunction * obj =
|
||||
ObjFunction::Create("reg:squarederror", &lparam);
|
||||
ObjFunction* obj = ObjFunction::Create("reg:squarederror", &ctx);
|
||||
HostDeviceVector<GradientPair> cpu_out_preds;
|
||||
HostDeviceVector<GradientPair> cuda_out_preds;
|
||||
|
||||
@@ -309,12 +300,12 @@ TEST(Objective, CPU_vs_CUDA) {
|
||||
|
||||
{
|
||||
// CPU
|
||||
lparam.gpu_id = -1;
|
||||
ctx.gpu_id = -1;
|
||||
obj->GetGradient(preds, info, 0, &cpu_out_preds);
|
||||
}
|
||||
{
|
||||
// CUDA
|
||||
lparam.gpu_id = 0;
|
||||
ctx.gpu_id = 0;
|
||||
obj->GetGradient(preds, info, 0, &cuda_out_preds);
|
||||
}
|
||||
|
||||
@@ -335,11 +326,9 @@ TEST(Objective, CPU_vs_CUDA) {
|
||||
#endif
|
||||
|
||||
TEST(Objective, DeclareUnifiedTest(TweedieRegressionBasic)) {
|
||||
GenericParameter lparam = CreateEmptyGenericParam(GPUIDX);
|
||||
Context ctx = CreateEmptyGenericParam(GPUIDX);
|
||||
std::vector<std::pair<std::string, std::string>> args;
|
||||
std::unique_ptr<ObjFunction> obj {
|
||||
ObjFunction::Create("reg:tweedie", &lparam)
|
||||
};
|
||||
std::unique_ptr<ObjFunction> obj{ObjFunction::Create("reg:tweedie", &ctx)};
|
||||
|
||||
obj->Configure(args);
|
||||
CheckConfigReload(obj, "reg:tweedie");
|
||||
@@ -366,11 +355,9 @@ TEST(Objective, DeclareUnifiedTest(TweedieRegressionBasic)) {
|
||||
// CoxRegression not implemented in GPU code, no need for testing.
|
||||
#if !defined(__CUDACC__)
|
||||
TEST(Objective, CoxRegressionGPair) {
|
||||
GenericParameter lparam = CreateEmptyGenericParam(GPUIDX);
|
||||
Context ctx = CreateEmptyGenericParam(GPUIDX);
|
||||
std::vector<std::pair<std::string, std::string>> args;
|
||||
std::unique_ptr<ObjFunction> obj {
|
||||
ObjFunction::Create("survival:cox", &lparam)
|
||||
};
|
||||
std::unique_ptr<ObjFunction> obj{ObjFunction::Create("survival:cox", &ctx)};
|
||||
|
||||
obj->Configure(args);
|
||||
CheckObjFunction(obj,
|
||||
|
||||
Reference in New Issue
Block a user