Switch back to the GPUIDX macro (#9438)
This commit is contained in:
parent
1aabc690ec
commit
bde1ebc209
@ -351,7 +351,7 @@ void TestAllReduceBasic() {
|
|||||||
auto const world = collective::GetWorldSize();
|
auto const world = collective::GetWorldSize();
|
||||||
constexpr size_t kRows = 1000, kCols = 100;
|
constexpr size_t kRows = 1000, kCols = 100;
|
||||||
RunWithSeedsAndBins(kRows, [=](int32_t seed, size_t n_bins, MetaInfo const& info) {
|
RunWithSeedsAndBins(kRows, [=](int32_t seed, size_t n_bins, MetaInfo const& info) {
|
||||||
auto const device = GetGPUId();
|
auto const device = GPUIDX;
|
||||||
|
|
||||||
// Set up single node version;
|
// Set up single node version;
|
||||||
HostDeviceVector<FeatureType> ft({}, device);
|
HostDeviceVector<FeatureType> ft({}, device);
|
||||||
@ -440,7 +440,7 @@ void TestColumnSplitBasic() {
|
|||||||
}()};
|
}()};
|
||||||
|
|
||||||
// Generate cuts for distributed environment.
|
// Generate cuts for distributed environment.
|
||||||
auto ctx = MakeCUDACtx(GetGPUId());
|
auto ctx = MakeCUDACtx(GPUIDX);
|
||||||
HistogramCuts distributed_cuts = common::DeviceSketch(&ctx, m.get(), kBins);
|
HistogramCuts distributed_cuts = common::DeviceSketch(&ctx, m.get(), kBins);
|
||||||
|
|
||||||
// Generate cuts for single node environment
|
// Generate cuts for single node environment
|
||||||
@ -483,7 +483,7 @@ void TestSameOnAllWorkers() {
|
|||||||
RunWithSeedsAndBins(kRows, [=](int32_t seed, size_t n_bins,
|
RunWithSeedsAndBins(kRows, [=](int32_t seed, size_t n_bins,
|
||||||
MetaInfo const &info) {
|
MetaInfo const &info) {
|
||||||
auto const rank = collective::GetRank();
|
auto const rank = collective::GetRank();
|
||||||
auto const device = GetGPUId();
|
auto const device = GPUIDX;
|
||||||
HostDeviceVector<FeatureType> ft({}, device);
|
HostDeviceVector<FeatureType> ft({}, device);
|
||||||
SketchContainer sketch_distributed(ft, n_bins, kCols, kRows, device);
|
SketchContainer sketch_distributed(ft, n_bins, kCols, kRows, device);
|
||||||
HostDeviceVector<float> storage({}, device);
|
HostDeviceVector<float> storage({}, device);
|
||||||
|
|||||||
@ -34,6 +34,12 @@
|
|||||||
#define DeclareUnifiedTest(name) name
|
#define DeclareUnifiedTest(name) name
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__CUDACC__)
|
||||||
|
#define GPUIDX (common::AllVisibleGPUs() == 1 ? 0 : collective::GetRank())
|
||||||
|
#else
|
||||||
|
#define GPUIDX (-1)
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(__CUDACC__)
|
#if defined(__CUDACC__)
|
||||||
#define DeclareUnifiedDistributedTest(name) MGPU ## name
|
#define DeclareUnifiedDistributedTest(name) MGPU ## name
|
||||||
#else
|
#else
|
||||||
@ -540,15 +546,6 @@ void RunWithInMemoryCommunicator(int32_t world_size, Function&& function, Args&&
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int GetGPUId() {
|
|
||||||
#if defined(__CUDACC__)
|
|
||||||
auto const n_gpus = common::AllVisibleGPUs();
|
|
||||||
return n_gpus == 1 ? 0 : collective::GetRank();
|
|
||||||
#else
|
|
||||||
return -1;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
class BaseMGPUTest : public ::testing::Test {
|
class BaseMGPUTest : public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
int world_size_;
|
int world_size_;
|
||||||
|
|||||||
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
namespace xgboost {
|
namespace xgboost {
|
||||||
inline void TestUpdaterJsonIO(std::string updater_str) {
|
inline void TestUpdaterJsonIO(std::string updater_str) {
|
||||||
Context ctx{MakeCUDACtx(GetGPUId())};
|
Context ctx{MakeCUDACtx(GPUIDX)};
|
||||||
Json config_0 {Object() };
|
Json config_0 {Object() };
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
@ -17,7 +17,7 @@ TEST(Linear, Shotgun) {
|
|||||||
|
|
||||||
auto p_fmat = xgboost::RandomDataGenerator(kRows, kCols, 0).GenerateDMatrix();
|
auto p_fmat = xgboost::RandomDataGenerator(kRows, kCols, 0).GenerateDMatrix();
|
||||||
|
|
||||||
auto ctx = MakeCUDACtx(GetGPUId());
|
auto ctx = MakeCUDACtx(GPUIDX);
|
||||||
LearnerModelParam mparam{MakeMP(kCols, .5, 1)};
|
LearnerModelParam mparam{MakeMP(kCols, .5, 1)};
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -49,7 +49,7 @@ TEST(Linear, coordinate) {
|
|||||||
|
|
||||||
auto p_fmat = xgboost::RandomDataGenerator(kRows, kCols, 0).GenerateDMatrix();
|
auto p_fmat = xgboost::RandomDataGenerator(kRows, kCols, 0).GenerateDMatrix();
|
||||||
|
|
||||||
auto ctx = MakeCUDACtx(GetGPUId());
|
auto ctx = MakeCUDACtx(GPUIDX);
|
||||||
LearnerModelParam mparam{MakeMP(kCols, .5, 1)};
|
LearnerModelParam mparam{MakeMP(kCols, .5, 1)};
|
||||||
|
|
||||||
auto updater = std::unique_ptr<xgboost::LinearUpdater>(
|
auto updater = std::unique_ptr<xgboost::LinearUpdater>(
|
||||||
|
|||||||
@ -11,7 +11,7 @@ namespace xgboost {
|
|||||||
namespace metric {
|
namespace metric {
|
||||||
|
|
||||||
inline void VerifyBinaryAUC(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
inline void VerifyBinaryAUC(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
||||||
auto ctx = MakeCUDACtx(GetGPUId());
|
auto ctx = MakeCUDACtx(GPUIDX);
|
||||||
std::unique_ptr<Metric> uni_ptr{Metric::Create("auc", &ctx)};
|
std::unique_ptr<Metric> uni_ptr{Metric::Create("auc", &ctx)};
|
||||||
Metric* metric = uni_ptr.get();
|
Metric* metric = uni_ptr.get();
|
||||||
ASSERT_STREQ(metric->Name(), "auc");
|
ASSERT_STREQ(metric->Name(), "auc");
|
||||||
@ -54,7 +54,7 @@ inline void VerifyBinaryAUC(DataSplitMode data_split_mode = DataSplitMode::kRow)
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline void VerifyMultiClassAUC(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
inline void VerifyMultiClassAUC(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
||||||
auto ctx = MakeCUDACtx(GetGPUId());
|
auto ctx = MakeCUDACtx(GPUIDX);
|
||||||
std::unique_ptr<Metric> uni_ptr{Metric::Create("auc", &ctx)};
|
std::unique_ptr<Metric> uni_ptr{Metric::Create("auc", &ctx)};
|
||||||
auto metric = uni_ptr.get();
|
auto metric = uni_ptr.get();
|
||||||
|
|
||||||
@ -115,7 +115,7 @@ inline void VerifyMultiClassAUC(DataSplitMode data_split_mode = DataSplitMode::k
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline void VerifyRankingAUC(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
inline void VerifyRankingAUC(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
||||||
auto ctx = MakeCUDACtx(GetGPUId());
|
auto ctx = MakeCUDACtx(GPUIDX);
|
||||||
std::unique_ptr<Metric> metric{Metric::Create("auc", &ctx)};
|
std::unique_ptr<Metric> metric{Metric::Create("auc", &ctx)};
|
||||||
|
|
||||||
// single group
|
// single group
|
||||||
@ -149,7 +149,7 @@ inline void VerifyRankingAUC(DataSplitMode data_split_mode = DataSplitMode::kRow
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline void VerifyPRAUC(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
inline void VerifyPRAUC(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
||||||
auto ctx = MakeCUDACtx(GetGPUId());
|
auto ctx = MakeCUDACtx(GPUIDX);
|
||||||
|
|
||||||
xgboost::Metric* metric = xgboost::Metric::Create("aucpr", &ctx);
|
xgboost::Metric* metric = xgboost::Metric::Create("aucpr", &ctx);
|
||||||
ASSERT_STREQ(metric->Name(), "aucpr");
|
ASSERT_STREQ(metric->Name(), "aucpr");
|
||||||
@ -186,7 +186,7 @@ inline void VerifyPRAUC(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline void VerifyMultiClassPRAUC(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
inline void VerifyMultiClassPRAUC(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
||||||
auto ctx = MakeCUDACtx(GetGPUId());
|
auto ctx = MakeCUDACtx(GPUIDX);
|
||||||
|
|
||||||
std::unique_ptr<Metric> metric{Metric::Create("aucpr", &ctx)};
|
std::unique_ptr<Metric> metric{Metric::Create("aucpr", &ctx)};
|
||||||
|
|
||||||
@ -210,7 +210,7 @@ inline void VerifyMultiClassPRAUC(DataSplitMode data_split_mode = DataSplitMode:
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline void VerifyRankingPRAUC(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
inline void VerifyRankingPRAUC(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
||||||
auto ctx = MakeCUDACtx(GetGPUId());
|
auto ctx = MakeCUDACtx(GPUIDX);
|
||||||
|
|
||||||
std::unique_ptr<Metric> metric{Metric::Create("aucpr", &ctx)};
|
std::unique_ptr<Metric> metric{Metric::Create("aucpr", &ctx)};
|
||||||
|
|
||||||
|
|||||||
@ -46,7 +46,7 @@ inline void CheckDeterministicMetricElementWise(StringView name, int32_t device)
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline void VerifyRMSE(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
inline void VerifyRMSE(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
||||||
auto ctx = MakeCUDACtx(GetGPUId());
|
auto ctx = MakeCUDACtx(GPUIDX);
|
||||||
xgboost::Metric * metric = xgboost::Metric::Create("rmse", &ctx);
|
xgboost::Metric * metric = xgboost::Metric::Create("rmse", &ctx);
|
||||||
metric->Configure({});
|
metric->Configure({});
|
||||||
ASSERT_STREQ(metric->Name(), "rmse");
|
ASSERT_STREQ(metric->Name(), "rmse");
|
||||||
@ -71,11 +71,11 @@ inline void VerifyRMSE(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
|||||||
0.6708f, 0.001f);
|
0.6708f, 0.001f);
|
||||||
delete metric;
|
delete metric;
|
||||||
|
|
||||||
CheckDeterministicMetricElementWise(StringView{"rmse"}, GetGPUId());
|
CheckDeterministicMetricElementWise(StringView{"rmse"}, GPUIDX);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void VerifyRMSLE(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
inline void VerifyRMSLE(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
||||||
auto ctx = MakeCUDACtx(GetGPUId());
|
auto ctx = MakeCUDACtx(GPUIDX);
|
||||||
xgboost::Metric * metric = xgboost::Metric::Create("rmsle", &ctx);
|
xgboost::Metric * metric = xgboost::Metric::Create("rmsle", &ctx);
|
||||||
metric->Configure({});
|
metric->Configure({});
|
||||||
ASSERT_STREQ(metric->Name(), "rmsle");
|
ASSERT_STREQ(metric->Name(), "rmsle");
|
||||||
@ -100,11 +100,11 @@ inline void VerifyRMSLE(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
|||||||
0.2415f, 1e-4);
|
0.2415f, 1e-4);
|
||||||
delete metric;
|
delete metric;
|
||||||
|
|
||||||
CheckDeterministicMetricElementWise(StringView{"rmsle"}, GetGPUId());
|
CheckDeterministicMetricElementWise(StringView{"rmsle"}, GPUIDX);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void VerifyMAE(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
inline void VerifyMAE(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
||||||
auto ctx = MakeCUDACtx(GetGPUId());
|
auto ctx = MakeCUDACtx(GPUIDX);
|
||||||
xgboost::Metric * metric = xgboost::Metric::Create("mae", &ctx);
|
xgboost::Metric * metric = xgboost::Metric::Create("mae", &ctx);
|
||||||
metric->Configure({});
|
metric->Configure({});
|
||||||
ASSERT_STREQ(metric->Name(), "mae");
|
ASSERT_STREQ(metric->Name(), "mae");
|
||||||
@ -129,11 +129,11 @@ inline void VerifyMAE(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
|||||||
0.54f, 0.001f);
|
0.54f, 0.001f);
|
||||||
delete metric;
|
delete metric;
|
||||||
|
|
||||||
CheckDeterministicMetricElementWise(StringView{"mae"}, GetGPUId());
|
CheckDeterministicMetricElementWise(StringView{"mae"}, GPUIDX);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void VerifyMAPE(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
inline void VerifyMAPE(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
||||||
auto ctx = MakeCUDACtx(GetGPUId());
|
auto ctx = MakeCUDACtx(GPUIDX);
|
||||||
xgboost::Metric * metric = xgboost::Metric::Create("mape", &ctx);
|
xgboost::Metric * metric = xgboost::Metric::Create("mape", &ctx);
|
||||||
metric->Configure({});
|
metric->Configure({});
|
||||||
ASSERT_STREQ(metric->Name(), "mape");
|
ASSERT_STREQ(metric->Name(), "mape");
|
||||||
@ -158,11 +158,11 @@ inline void VerifyMAPE(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
|||||||
1.3250f, 0.001f);
|
1.3250f, 0.001f);
|
||||||
delete metric;
|
delete metric;
|
||||||
|
|
||||||
CheckDeterministicMetricElementWise(StringView{"mape"}, GetGPUId());
|
CheckDeterministicMetricElementWise(StringView{"mape"}, GPUIDX);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void VerifyMPHE(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
inline void VerifyMPHE(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
||||||
auto ctx = MakeCUDACtx(GetGPUId());
|
auto ctx = MakeCUDACtx(GPUIDX);
|
||||||
std::unique_ptr<xgboost::Metric> metric{xgboost::Metric::Create("mphe", &ctx)};
|
std::unique_ptr<xgboost::Metric> metric{xgboost::Metric::Create("mphe", &ctx)};
|
||||||
metric->Configure({});
|
metric->Configure({});
|
||||||
ASSERT_STREQ(metric->Name(), "mphe");
|
ASSERT_STREQ(metric->Name(), "mphe");
|
||||||
@ -186,7 +186,7 @@ inline void VerifyMPHE(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
|||||||
{ 1, 2, 9, 8}, {}, data_split_mode),
|
{ 1, 2, 9, 8}, {}, data_split_mode),
|
||||||
0.1922f, 1e-4);
|
0.1922f, 1e-4);
|
||||||
|
|
||||||
CheckDeterministicMetricElementWise(StringView{"mphe"}, GetGPUId());
|
CheckDeterministicMetricElementWise(StringView{"mphe"}, GPUIDX);
|
||||||
|
|
||||||
metric->Configure({{"huber_slope", "0.1"}});
|
metric->Configure({{"huber_slope", "0.1"}});
|
||||||
EXPECT_NEAR(GetMetricEval(metric.get(),
|
EXPECT_NEAR(GetMetricEval(metric.get(),
|
||||||
@ -197,7 +197,7 @@ inline void VerifyMPHE(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline void VerifyLogLoss(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
inline void VerifyLogLoss(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
||||||
auto ctx = MakeCUDACtx(GetGPUId());
|
auto ctx = MakeCUDACtx(GPUIDX);
|
||||||
xgboost::Metric * metric = xgboost::Metric::Create("logloss", &ctx);
|
xgboost::Metric * metric = xgboost::Metric::Create("logloss", &ctx);
|
||||||
metric->Configure({});
|
metric->Configure({});
|
||||||
ASSERT_STREQ(metric->Name(), "logloss");
|
ASSERT_STREQ(metric->Name(), "logloss");
|
||||||
@ -226,11 +226,11 @@ inline void VerifyLogLoss(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
|||||||
1.3138f, 0.001f);
|
1.3138f, 0.001f);
|
||||||
delete metric;
|
delete metric;
|
||||||
|
|
||||||
CheckDeterministicMetricElementWise(StringView{"logloss"}, GetGPUId());
|
CheckDeterministicMetricElementWise(StringView{"logloss"}, GPUIDX);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void VerifyError(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
inline void VerifyError(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
||||||
auto ctx = MakeCUDACtx(GetGPUId());
|
auto ctx = MakeCUDACtx(GPUIDX);
|
||||||
xgboost::Metric * metric = xgboost::Metric::Create("error", &ctx);
|
xgboost::Metric * metric = xgboost::Metric::Create("error", &ctx);
|
||||||
metric->Configure({});
|
metric->Configure({});
|
||||||
ASSERT_STREQ(metric->Name(), "error");
|
ASSERT_STREQ(metric->Name(), "error");
|
||||||
@ -288,11 +288,11 @@ inline void VerifyError(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
|||||||
0.45f, 0.001f);
|
0.45f, 0.001f);
|
||||||
delete metric;
|
delete metric;
|
||||||
|
|
||||||
CheckDeterministicMetricElementWise(StringView{"error@0.5"}, GetGPUId());
|
CheckDeterministicMetricElementWise(StringView{"error@0.5"}, GPUIDX);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void VerifyPoissonNegLogLik(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
inline void VerifyPoissonNegLogLik(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
||||||
auto ctx = MakeCUDACtx(GetGPUId());
|
auto ctx = MakeCUDACtx(GPUIDX);
|
||||||
xgboost::Metric * metric = xgboost::Metric::Create("poisson-nloglik", &ctx);
|
xgboost::Metric * metric = xgboost::Metric::Create("poisson-nloglik", &ctx);
|
||||||
metric->Configure({});
|
metric->Configure({});
|
||||||
ASSERT_STREQ(metric->Name(), "poisson-nloglik");
|
ASSERT_STREQ(metric->Name(), "poisson-nloglik");
|
||||||
@ -321,18 +321,18 @@ inline void VerifyPoissonNegLogLik(DataSplitMode data_split_mode = DataSplitMode
|
|||||||
1.5783f, 0.001f);
|
1.5783f, 0.001f);
|
||||||
delete metric;
|
delete metric;
|
||||||
|
|
||||||
CheckDeterministicMetricElementWise(StringView{"poisson-nloglik"}, GetGPUId());
|
CheckDeterministicMetricElementWise(StringView{"poisson-nloglik"}, GPUIDX);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void VerifyMultiRMSE(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
inline void VerifyMultiRMSE(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
||||||
size_t n_samples = 32, n_targets = 8;
|
size_t n_samples = 32, n_targets = 8;
|
||||||
linalg::Tensor<float, 2> y{{n_samples, n_targets}, GetGPUId()};
|
linalg::Tensor<float, 2> y{{n_samples, n_targets}, GPUIDX};
|
||||||
auto &h_y = y.Data()->HostVector();
|
auto &h_y = y.Data()->HostVector();
|
||||||
std::iota(h_y.begin(), h_y.end(), 0);
|
std::iota(h_y.begin(), h_y.end(), 0);
|
||||||
|
|
||||||
HostDeviceVector<float> predt(n_samples * n_targets, 0);
|
HostDeviceVector<float> predt(n_samples * n_targets, 0);
|
||||||
|
|
||||||
auto ctx = MakeCUDACtx(GetGPUId());
|
auto ctx = MakeCUDACtx(GPUIDX);
|
||||||
std::unique_ptr<Metric> metric{Metric::Create("rmse", &ctx)};
|
std::unique_ptr<Metric> metric{Metric::Create("rmse", &ctx)};
|
||||||
metric->Configure({});
|
metric->Configure({});
|
||||||
|
|
||||||
@ -347,7 +347,7 @@ inline void VerifyMultiRMSE(DataSplitMode data_split_mode = DataSplitMode::kRow)
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline void VerifyQuantile(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
inline void VerifyQuantile(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
||||||
auto ctx = MakeCUDACtx(GetGPUId());
|
auto ctx = MakeCUDACtx(GPUIDX);
|
||||||
std::unique_ptr<Metric> metric{Metric::Create("quantile", &ctx)};
|
std::unique_ptr<Metric> metric{Metric::Create("quantile", &ctx)};
|
||||||
|
|
||||||
HostDeviceVector<float> predts{0.1f, 0.9f, 0.1f, 0.9f};
|
HostDeviceVector<float> predts{0.1f, 0.9f, 0.1f, 0.9f};
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
#include "../helpers.h"
|
#include "../helpers.h"
|
||||||
namespace xgboost {
|
namespace xgboost {
|
||||||
TEST(Metric, UnknownMetric) {
|
TEST(Metric, UnknownMetric) {
|
||||||
auto ctx = MakeCUDACtx(GetGPUId());
|
auto ctx = MakeCUDACtx(GPUIDX);
|
||||||
xgboost::Metric* metric = nullptr;
|
xgboost::Metric* metric = nullptr;
|
||||||
EXPECT_ANY_THROW(metric = xgboost::Metric::Create("unknown_name", &ctx));
|
EXPECT_ANY_THROW(metric = xgboost::Metric::Create("unknown_name", &ctx));
|
||||||
EXPECT_NO_THROW(metric = xgboost::Metric::Create("rmse", &ctx));
|
EXPECT_NO_THROW(metric = xgboost::Metric::Create("rmse", &ctx));
|
||||||
|
|||||||
@ -60,8 +60,8 @@ inline void TestMultiClassError(int device, DataSplitMode data_split_mode) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline void VerifyMultiClassError(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
inline void VerifyMultiClassError(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
||||||
TestMultiClassError(GetGPUId(), data_split_mode);
|
TestMultiClassError(GPUIDX, data_split_mode);
|
||||||
CheckDeterministicMetricMultiClass(StringView{"merror"}, GetGPUId());
|
CheckDeterministicMetricMultiClass(StringView{"merror"}, GPUIDX);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void TestMultiClassLogLoss(int device, DataSplitMode data_split_mode) {
|
inline void TestMultiClassLogLoss(int device, DataSplitMode data_split_mode) {
|
||||||
@ -81,8 +81,8 @@ inline void TestMultiClassLogLoss(int device, DataSplitMode data_split_mode) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline void VerifyMultiClassLogLoss(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
inline void VerifyMultiClassLogLoss(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
||||||
TestMultiClassLogLoss(GetGPUId(), data_split_mode);
|
TestMultiClassLogLoss(GPUIDX, data_split_mode);
|
||||||
CheckDeterministicMetricMultiClass(StringView{"mlogloss"}, GetGPUId());
|
CheckDeterministicMetricMultiClass(StringView{"mlogloss"}, GPUIDX);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace metric
|
} // namespace metric
|
||||||
|
|||||||
@ -22,7 +22,7 @@ namespace metric {
|
|||||||
|
|
||||||
#if !defined(__CUDACC__)
|
#if !defined(__CUDACC__)
|
||||||
TEST(Metric, AMS) {
|
TEST(Metric, AMS) {
|
||||||
auto ctx = MakeCUDACtx(GetGPUId());
|
auto ctx = MakeCUDACtx(GPUIDX);
|
||||||
EXPECT_ANY_THROW(Metric::Create("ams", &ctx));
|
EXPECT_ANY_THROW(Metric::Create("ams", &ctx));
|
||||||
Metric* metric = Metric::Create("ams@0.5f", &ctx);
|
Metric* metric = Metric::Create("ams@0.5f", &ctx);
|
||||||
ASSERT_STREQ(metric->Name(), "ams@0.5");
|
ASSERT_STREQ(metric->Name(), "ams@0.5");
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
namespace xgboost::metric {
|
namespace xgboost::metric {
|
||||||
|
|
||||||
inline void VerifyPrecision(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
inline void VerifyPrecision(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
||||||
auto ctx = MakeCUDACtx(GetGPUId());
|
auto ctx = MakeCUDACtx(GPUIDX);
|
||||||
std::unique_ptr<xgboost::Metric> metric{Metric::Create("pre", &ctx)};
|
std::unique_ptr<xgboost::Metric> metric{Metric::Create("pre", &ctx)};
|
||||||
ASSERT_STREQ(metric->Name(), "pre");
|
ASSERT_STREQ(metric->Name(), "pre");
|
||||||
EXPECT_NEAR(GetMetricEval(metric.get(), {0, 1}, {0, 1}, {}, {}, data_split_mode), 0.5, 1e-7);
|
EXPECT_NEAR(GetMetricEval(metric.get(), {0, 1}, {0, 1}, {}, {}, data_split_mode), 0.5, 1e-7);
|
||||||
@ -44,7 +44,7 @@ inline void VerifyPrecision(DataSplitMode data_split_mode = DataSplitMode::kRow)
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline void VerifyNDCG(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
inline void VerifyNDCG(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
||||||
auto ctx = MakeCUDACtx(GetGPUId());
|
auto ctx = MakeCUDACtx(GPUIDX);
|
||||||
Metric * metric = xgboost::Metric::Create("ndcg", &ctx);
|
Metric * metric = xgboost::Metric::Create("ndcg", &ctx);
|
||||||
ASSERT_STREQ(metric->Name(), "ndcg");
|
ASSERT_STREQ(metric->Name(), "ndcg");
|
||||||
EXPECT_ANY_THROW(GetMetricEval(metric, {0, 1}, {}, {}, {}, data_split_mode));
|
EXPECT_ANY_THROW(GetMetricEval(metric, {0, 1}, {}, {}, {}, data_split_mode));
|
||||||
@ -102,7 +102,7 @@ inline void VerifyNDCG(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline void VerifyMAP(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
inline void VerifyMAP(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
||||||
auto ctx = MakeCUDACtx(GetGPUId());
|
auto ctx = MakeCUDACtx(GPUIDX);
|
||||||
Metric * metric = xgboost::Metric::Create("map", &ctx);
|
Metric * metric = xgboost::Metric::Create("map", &ctx);
|
||||||
ASSERT_STREQ(metric->Name(), "map");
|
ASSERT_STREQ(metric->Name(), "map");
|
||||||
EXPECT_NEAR(GetMetricEval(metric, {0, 1}, {0, 1}, {}, {}, data_split_mode), 1, kRtEps);
|
EXPECT_NEAR(GetMetricEval(metric, {0, 1}, {0, 1}, {}, {}, data_split_mode), 1, kRtEps);
|
||||||
@ -150,7 +150,7 @@ inline void VerifyMAP(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline void VerifyNDCGExpGain(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
inline void VerifyNDCGExpGain(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
||||||
Context ctx = MakeCUDACtx(GetGPUId());
|
Context ctx = MakeCUDACtx(GPUIDX);
|
||||||
|
|
||||||
auto p_fmat = xgboost::RandomDataGenerator{0, 0, 0}.GenerateDMatrix();
|
auto p_fmat = xgboost::RandomDataGenerator{0, 0, 0}.GenerateDMatrix();
|
||||||
MetaInfo& info = p_fmat->Info();
|
MetaInfo& info = p_fmat->Info();
|
||||||
|
|||||||
@ -31,7 +31,7 @@ TEST_F(DeclareUnifiedDistributedTest(MetricTest), IntervalRegressionAccuracyColu
|
|||||||
|
|
||||||
// Test configuration of AFT metric
|
// Test configuration of AFT metric
|
||||||
TEST(AFTNegLogLikMetric, DeclareUnifiedTest(Configuration)) {
|
TEST(AFTNegLogLikMetric, DeclareUnifiedTest(Configuration)) {
|
||||||
auto ctx = MakeCUDACtx(GetGPUId());
|
auto ctx = MakeCUDACtx(GPUIDX);
|
||||||
std::unique_ptr<Metric> metric(Metric::Create("aft-nloglik", &ctx));
|
std::unique_ptr<Metric> metric(Metric::Create("aft-nloglik", &ctx));
|
||||||
metric->Configure({{"aft_loss_distribution", "normal"}, {"aft_loss_distribution_scale", "10"}});
|
metric->Configure({{"aft_loss_distribution", "normal"}, {"aft_loss_distribution_scale", "10"}});
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ TEST(AFTNegLogLikMetric, DeclareUnifiedTest(Configuration)) {
|
|||||||
EXPECT_EQ(get<String>(aft_param_json["aft_loss_distribution"]), "normal");
|
EXPECT_EQ(get<String>(aft_param_json["aft_loss_distribution"]), "normal");
|
||||||
EXPECT_EQ(get<String>(aft_param_json["aft_loss_distribution_scale"]), "10");
|
EXPECT_EQ(get<String>(aft_param_json["aft_loss_distribution_scale"]), "10");
|
||||||
|
|
||||||
CheckDeterministicMetricElementWise(StringView{"aft-nloglik"}, GetGPUId());
|
CheckDeterministicMetricElementWise(StringView{"aft-nloglik"}, GPUIDX);
|
||||||
}
|
}
|
||||||
} // namespace common
|
} // namespace common
|
||||||
} // namespace xgboost
|
} // namespace xgboost
|
||||||
|
|||||||
@ -48,7 +48,7 @@ inline void CheckDeterministicMetricElementWise(StringView name, int32_t device)
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline void VerifyAFTNegLogLik(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
inline void VerifyAFTNegLogLik(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
||||||
auto ctx = MakeCUDACtx(GetGPUId());
|
auto ctx = MakeCUDACtx(GPUIDX);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test aggregate output from the AFT metric over a small test data set.
|
* Test aggregate output from the AFT metric over a small test data set.
|
||||||
@ -79,7 +79,7 @@ inline void VerifyAFTNegLogLik(DataSplitMode data_split_mode = DataSplitMode::kR
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline void VerifyIntervalRegressionAccuracy(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
inline void VerifyIntervalRegressionAccuracy(DataSplitMode data_split_mode = DataSplitMode::kRow) {
|
||||||
auto ctx = MakeCUDACtx(GetGPUId());
|
auto ctx = MakeCUDACtx(GPUIDX);
|
||||||
|
|
||||||
auto p_fmat = EmptyDMatrix();
|
auto p_fmat = EmptyDMatrix();
|
||||||
MetaInfo& info = p_fmat->Info();
|
MetaInfo& info = p_fmat->Info();
|
||||||
@ -101,7 +101,7 @@ inline void VerifyIntervalRegressionAccuracy(DataSplitMode data_split_mode = Dat
|
|||||||
info.labels_lower_bound_.HostVector()[0] = 70.0f;
|
info.labels_lower_bound_.HostVector()[0] = 70.0f;
|
||||||
EXPECT_FLOAT_EQ(metric->Evaluate(preds, p_fmat), 0.25f);
|
EXPECT_FLOAT_EQ(metric->Evaluate(preds, p_fmat), 0.25f);
|
||||||
|
|
||||||
CheckDeterministicMetricElementWise(StringView{"interval-regression-accuracy"}, GetGPUId());
|
CheckDeterministicMetricElementWise(StringView{"interval-regression-accuracy"}, GPUIDX);
|
||||||
}
|
}
|
||||||
} // namespace common
|
} // namespace common
|
||||||
} // namespace xgboost
|
} // namespace xgboost
|
||||||
|
|||||||
@ -16,7 +16,7 @@ namespace xgboost {
|
|||||||
namespace common {
|
namespace common {
|
||||||
|
|
||||||
TEST(Objective, DeclareUnifiedTest(AFTObjConfiguration)) {
|
TEST(Objective, DeclareUnifiedTest(AFTObjConfiguration)) {
|
||||||
auto ctx = MakeCUDACtx(GetGPUId());
|
auto ctx = MakeCUDACtx(GPUIDX);
|
||||||
std::unique_ptr<ObjFunction> objective(ObjFunction::Create("survival:aft", &ctx));
|
std::unique_ptr<ObjFunction> objective(ObjFunction::Create("survival:aft", &ctx));
|
||||||
objective->Configure({ {"aft_loss_distribution", "logistic"},
|
objective->Configure({ {"aft_loss_distribution", "logistic"},
|
||||||
{"aft_loss_distribution_scale", "5"} });
|
{"aft_loss_distribution_scale", "5"} });
|
||||||
@ -77,7 +77,7 @@ static inline void CheckGPairOverGridPoints(
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(Objective, DeclareUnifiedTest(AFTObjGPairUncensoredLabels)) {
|
TEST(Objective, DeclareUnifiedTest(AFTObjGPairUncensoredLabels)) {
|
||||||
auto ctx = MakeCUDACtx(GetGPUId());
|
auto ctx = MakeCUDACtx(GPUIDX);
|
||||||
std::unique_ptr<ObjFunction> obj(ObjFunction::Create("survival:aft", &ctx));
|
std::unique_ptr<ObjFunction> obj(ObjFunction::Create("survival:aft", &ctx));
|
||||||
|
|
||||||
CheckGPairOverGridPoints(obj.get(), 100.0f, 100.0f, "normal",
|
CheckGPairOverGridPoints(obj.get(), 100.0f, 100.0f, "normal",
|
||||||
@ -101,7 +101,7 @@ TEST(Objective, DeclareUnifiedTest(AFTObjGPairUncensoredLabels)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(Objective, DeclareUnifiedTest(AFTObjGPairLeftCensoredLabels)) {
|
TEST(Objective, DeclareUnifiedTest(AFTObjGPairLeftCensoredLabels)) {
|
||||||
auto ctx = MakeCUDACtx(GetGPUId());
|
auto ctx = MakeCUDACtx(GPUIDX);
|
||||||
std::unique_ptr<ObjFunction> obj(ObjFunction::Create("survival:aft", &ctx));
|
std::unique_ptr<ObjFunction> obj(ObjFunction::Create("survival:aft", &ctx));
|
||||||
|
|
||||||
CheckGPairOverGridPoints(obj.get(), 0.0f, 20.0f, "normal",
|
CheckGPairOverGridPoints(obj.get(), 0.0f, 20.0f, "normal",
|
||||||
@ -122,7 +122,7 @@ TEST(Objective, DeclareUnifiedTest(AFTObjGPairLeftCensoredLabels)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(Objective, DeclareUnifiedTest(AFTObjGPairRightCensoredLabels)) {
|
TEST(Objective, DeclareUnifiedTest(AFTObjGPairRightCensoredLabels)) {
|
||||||
auto ctx = MakeCUDACtx(GetGPUId());
|
auto ctx = MakeCUDACtx(GPUIDX);
|
||||||
std::unique_ptr<ObjFunction> obj(ObjFunction::Create("survival:aft", &ctx));
|
std::unique_ptr<ObjFunction> obj(ObjFunction::Create("survival:aft", &ctx));
|
||||||
|
|
||||||
CheckGPairOverGridPoints(obj.get(), 60.0f, std::numeric_limits<float>::infinity(), "normal",
|
CheckGPairOverGridPoints(obj.get(), 60.0f, std::numeric_limits<float>::infinity(), "normal",
|
||||||
@ -146,7 +146,7 @@ TEST(Objective, DeclareUnifiedTest(AFTObjGPairRightCensoredLabels)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(Objective, DeclareUnifiedTest(AFTObjGPairIntervalCensoredLabels)) {
|
TEST(Objective, DeclareUnifiedTest(AFTObjGPairIntervalCensoredLabels)) {
|
||||||
auto ctx = MakeCUDACtx(GetGPUId());
|
auto ctx = MakeCUDACtx(GPUIDX);
|
||||||
std::unique_ptr<ObjFunction> obj(ObjFunction::Create("survival:aft", &ctx));
|
std::unique_ptr<ObjFunction> obj(ObjFunction::Create("survival:aft", &ctx));
|
||||||
|
|
||||||
CheckGPairOverGridPoints(obj.get(), 16.0f, 200.0f, "normal",
|
CheckGPairOverGridPoints(obj.get(), 16.0f, 200.0f, "normal",
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
#include "../helpers.h"
|
#include "../helpers.h"
|
||||||
namespace xgboost {
|
namespace xgboost {
|
||||||
TEST(Objective, DeclareUnifiedTest(HingeObj)) {
|
TEST(Objective, DeclareUnifiedTest(HingeObj)) {
|
||||||
Context ctx = MakeCUDACtx(GetGPUId());
|
Context ctx = MakeCUDACtx(GPUIDX);
|
||||||
std::unique_ptr<ObjFunction> obj{ObjFunction::Create("binary:hinge", &ctx)};
|
std::unique_ptr<ObjFunction> obj{ObjFunction::Create("binary:hinge", &ctx)};
|
||||||
|
|
||||||
float eps = std::numeric_limits<xgboost::bst_float>::min();
|
float eps = std::numeric_limits<xgboost::bst_float>::min();
|
||||||
|
|||||||
@ -71,7 +71,7 @@ void TestNDCGGPair(Context const* ctx) {
|
|||||||
|
|
||||||
HostDeviceVector<float> predts{0, 1, 0, 1};
|
HostDeviceVector<float> predts{0, 1, 0, 1};
|
||||||
MetaInfo info;
|
MetaInfo info;
|
||||||
info.labels = linalg::Tensor<float, 2>{{0, 1, 0, 1}, {4, 1}, GetGPUId()};
|
info.labels = linalg::Tensor<float, 2>{{0, 1, 0, 1}, {4, 1}, GPUIDX};
|
||||||
info.group_ptr_ = {0, 2, 4};
|
info.group_ptr_ = {0, 2, 4};
|
||||||
info.num_row_ = 4;
|
info.num_row_ = 4;
|
||||||
HostDeviceVector<GradientPair> gpairs;
|
HostDeviceVector<GradientPair> gpairs;
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
namespace xgboost {
|
namespace xgboost {
|
||||||
|
|
||||||
TEST(Objective, DeclareUnifiedTest(SoftmaxMultiClassObjGPair)) {
|
TEST(Objective, DeclareUnifiedTest(SoftmaxMultiClassObjGPair)) {
|
||||||
Context ctx = MakeCUDACtx(GetGPUId());
|
Context ctx = MakeCUDACtx(GPUIDX);
|
||||||
std::vector<std::pair<std::string, std::string>> args {{"num_class", "3"}};
|
std::vector<std::pair<std::string, std::string>> args {{"num_class", "3"}};
|
||||||
std::unique_ptr<ObjFunction> obj {
|
std::unique_ptr<ObjFunction> obj {
|
||||||
ObjFunction::Create("multi:softmax", &ctx)
|
ObjFunction::Create("multi:softmax", &ctx)
|
||||||
@ -36,7 +36,7 @@ TEST(Objective, DeclareUnifiedTest(SoftmaxMultiClassObjGPair)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(Objective, DeclareUnifiedTest(SoftmaxMultiClassBasic)) {
|
TEST(Objective, DeclareUnifiedTest(SoftmaxMultiClassBasic)) {
|
||||||
auto ctx = MakeCUDACtx(GetGPUId());
|
auto ctx = MakeCUDACtx(GPUIDX);
|
||||||
std::vector<std::pair<std::string, std::string>> args{
|
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")};
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ TEST(Objective, DeclareUnifiedTest(SoftmaxMultiClassBasic)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(Objective, DeclareUnifiedTest(SoftprobMultiClassBasic)) {
|
TEST(Objective, DeclareUnifiedTest(SoftprobMultiClassBasic)) {
|
||||||
Context ctx = MakeCUDACtx(GetGPUId());
|
Context ctx = MakeCUDACtx(GPUIDX);
|
||||||
std::vector<std::pair<std::string, std::string>> args {
|
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")};
|
||||||
|
|
||||||
|
|||||||
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
namespace xgboost {
|
namespace xgboost {
|
||||||
TEST(Objective, DeclareUnifiedTest(Quantile)) {
|
TEST(Objective, DeclareUnifiedTest(Quantile)) {
|
||||||
Context ctx = MakeCUDACtx(GetGPUId());
|
Context ctx = MakeCUDACtx(GPUIDX);
|
||||||
|
|
||||||
{
|
{
|
||||||
Args args{{"quantile_alpha", "[0.6, 0.8]"}};
|
Args args{{"quantile_alpha", "[0.6, 0.8]"}};
|
||||||
@ -37,7 +37,7 @@ TEST(Objective, DeclareUnifiedTest(Quantile)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(Objective, DeclareUnifiedTest(QuantileIntercept)) {
|
TEST(Objective, DeclareUnifiedTest(QuantileIntercept)) {
|
||||||
Context ctx = MakeCUDACtx(GetGPUId());
|
Context ctx = MakeCUDACtx(GPUIDX);
|
||||||
Args args{{"quantile_alpha", "[0.6, 0.8]"}};
|
Args args{{"quantile_alpha", "[0.6, 0.8]"}};
|
||||||
std::unique_ptr<ObjFunction> obj{ObjFunction::Create("reg:quantileerror", &ctx)};
|
std::unique_ptr<ObjFunction> obj{ObjFunction::Create("reg:quantileerror", &ctx)};
|
||||||
obj->Configure(args);
|
obj->Configure(args);
|
||||||
|
|||||||
@ -17,7 +17,7 @@
|
|||||||
namespace xgboost {
|
namespace xgboost {
|
||||||
|
|
||||||
TEST(Objective, DeclareUnifiedTest(LinearRegressionGPair)) {
|
TEST(Objective, DeclareUnifiedTest(LinearRegressionGPair)) {
|
||||||
Context ctx = MakeCUDACtx(GetGPUId());
|
Context ctx = MakeCUDACtx(GPUIDX);
|
||||||
std::vector<std::pair<std::string, std::string>> args;
|
std::vector<std::pair<std::string, std::string>> args;
|
||||||
|
|
||||||
std::unique_ptr<ObjFunction> obj{ObjFunction::Create("reg:squarederror", &ctx)};
|
std::unique_ptr<ObjFunction> obj{ObjFunction::Create("reg:squarederror", &ctx)};
|
||||||
@ -39,7 +39,7 @@ TEST(Objective, DeclareUnifiedTest(LinearRegressionGPair)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(Objective, DeclareUnifiedTest(SquaredLog)) {
|
TEST(Objective, DeclareUnifiedTest(SquaredLog)) {
|
||||||
Context ctx = MakeCUDACtx(GetGPUId());
|
Context ctx = MakeCUDACtx(GPUIDX);
|
||||||
std::vector<std::pair<std::string, std::string>> args;
|
std::vector<std::pair<std::string, std::string>> args;
|
||||||
|
|
||||||
std::unique_ptr<ObjFunction> obj{ObjFunction::Create("reg:squaredlogerror", &ctx)};
|
std::unique_ptr<ObjFunction> obj{ObjFunction::Create("reg:squaredlogerror", &ctx)};
|
||||||
@ -62,7 +62,7 @@ TEST(Objective, DeclareUnifiedTest(SquaredLog)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(Objective, DeclareUnifiedTest(PseudoHuber)) {
|
TEST(Objective, DeclareUnifiedTest(PseudoHuber)) {
|
||||||
Context ctx = MakeCUDACtx(GetGPUId());
|
Context ctx = MakeCUDACtx(GPUIDX);
|
||||||
Args args;
|
Args args;
|
||||||
|
|
||||||
std::unique_ptr<ObjFunction> obj{ObjFunction::Create("reg:pseudohubererror", &ctx)};
|
std::unique_ptr<ObjFunction> obj{ObjFunction::Create("reg:pseudohubererror", &ctx)};
|
||||||
@ -91,7 +91,7 @@ TEST(Objective, DeclareUnifiedTest(PseudoHuber)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(Objective, DeclareUnifiedTest(LogisticRegressionGPair)) {
|
TEST(Objective, DeclareUnifiedTest(LogisticRegressionGPair)) {
|
||||||
Context ctx = MakeCUDACtx(GetGPUId());
|
Context ctx = MakeCUDACtx(GPUIDX);
|
||||||
std::vector<std::pair<std::string, std::string>> args;
|
std::vector<std::pair<std::string, std::string>> args;
|
||||||
std::unique_ptr<ObjFunction> obj{ObjFunction::Create("reg:logistic", &ctx)};
|
std::unique_ptr<ObjFunction> obj{ObjFunction::Create("reg:logistic", &ctx)};
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ TEST(Objective, DeclareUnifiedTest(LogisticRegressionGPair)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(Objective, DeclareUnifiedTest(LogisticRegressionBasic)) {
|
TEST(Objective, DeclareUnifiedTest(LogisticRegressionBasic)) {
|
||||||
Context ctx = MakeCUDACtx(GetGPUId());
|
Context ctx = MakeCUDACtx(GPUIDX);
|
||||||
std::vector<std::pair<std::string, std::string>> args;
|
std::vector<std::pair<std::string, std::string>> args;
|
||||||
std::unique_ptr<ObjFunction> obj{ObjFunction::Create("reg:logistic", &ctx)};
|
std::unique_ptr<ObjFunction> obj{ObjFunction::Create("reg:logistic", &ctx)};
|
||||||
|
|
||||||
@ -136,7 +136,7 @@ TEST(Objective, DeclareUnifiedTest(LogisticRegressionBasic)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(Objective, DeclareUnifiedTest(LogisticRawGPair)) {
|
TEST(Objective, DeclareUnifiedTest(LogisticRawGPair)) {
|
||||||
Context ctx = MakeCUDACtx(GetGPUId());
|
Context ctx = MakeCUDACtx(GPUIDX);
|
||||||
std::vector<std::pair<std::string, std::string>> args;
|
std::vector<std::pair<std::string, std::string>> args;
|
||||||
std::unique_ptr<ObjFunction> obj {
|
std::unique_ptr<ObjFunction> obj {
|
||||||
ObjFunction::Create("binary:logitraw", &ctx)
|
ObjFunction::Create("binary:logitraw", &ctx)
|
||||||
@ -152,7 +152,7 @@ TEST(Objective, DeclareUnifiedTest(LogisticRawGPair)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(Objective, DeclareUnifiedTest(PoissonRegressionGPair)) {
|
TEST(Objective, DeclareUnifiedTest(PoissonRegressionGPair)) {
|
||||||
Context ctx = MakeCUDACtx(GetGPUId());
|
Context ctx = MakeCUDACtx(GPUIDX);
|
||||||
std::vector<std::pair<std::string, std::string>> args;
|
std::vector<std::pair<std::string, std::string>> args;
|
||||||
std::unique_ptr<ObjFunction> obj {
|
std::unique_ptr<ObjFunction> obj {
|
||||||
ObjFunction::Create("count:poisson", &ctx)
|
ObjFunction::Create("count:poisson", &ctx)
|
||||||
@ -176,7 +176,7 @@ TEST(Objective, DeclareUnifiedTest(PoissonRegressionGPair)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(Objective, DeclareUnifiedTest(PoissonRegressionBasic)) {
|
TEST(Objective, DeclareUnifiedTest(PoissonRegressionBasic)) {
|
||||||
Context ctx = MakeCUDACtx(GetGPUId());
|
Context ctx = MakeCUDACtx(GPUIDX);
|
||||||
std::vector<std::pair<std::string, std::string>> args;
|
std::vector<std::pair<std::string, std::string>> args;
|
||||||
std::unique_ptr<ObjFunction> obj {
|
std::unique_ptr<ObjFunction> obj {
|
||||||
ObjFunction::Create("count:poisson", &ctx)
|
ObjFunction::Create("count:poisson", &ctx)
|
||||||
@ -205,7 +205,7 @@ TEST(Objective, DeclareUnifiedTest(PoissonRegressionBasic)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(Objective, DeclareUnifiedTest(GammaRegressionGPair)) {
|
TEST(Objective, DeclareUnifiedTest(GammaRegressionGPair)) {
|
||||||
Context ctx = MakeCUDACtx(GetGPUId());
|
Context ctx = MakeCUDACtx(GPUIDX);
|
||||||
std::vector<std::pair<std::string, std::string>> args;
|
std::vector<std::pair<std::string, std::string>> args;
|
||||||
std::unique_ptr<ObjFunction> obj {
|
std::unique_ptr<ObjFunction> obj {
|
||||||
ObjFunction::Create("reg:gamma", &ctx)
|
ObjFunction::Create("reg:gamma", &ctx)
|
||||||
@ -227,7 +227,7 @@ TEST(Objective, DeclareUnifiedTest(GammaRegressionGPair)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(Objective, DeclareUnifiedTest(GammaRegressionBasic)) {
|
TEST(Objective, DeclareUnifiedTest(GammaRegressionBasic)) {
|
||||||
Context ctx = MakeCUDACtx(GetGPUId());
|
Context ctx = MakeCUDACtx(GPUIDX);
|
||||||
std::vector<std::pair<std::string, std::string>> args;
|
std::vector<std::pair<std::string, std::string>> args;
|
||||||
std::unique_ptr<ObjFunction> obj{ObjFunction::Create("reg:gamma", &ctx)};
|
std::unique_ptr<ObjFunction> obj{ObjFunction::Create("reg:gamma", &ctx)};
|
||||||
|
|
||||||
@ -256,7 +256,7 @@ TEST(Objective, DeclareUnifiedTest(GammaRegressionBasic)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(Objective, DeclareUnifiedTest(TweedieRegressionGPair)) {
|
TEST(Objective, DeclareUnifiedTest(TweedieRegressionGPair)) {
|
||||||
Context ctx = MakeCUDACtx(GetGPUId());
|
Context ctx = MakeCUDACtx(GPUIDX);
|
||||||
std::vector<std::pair<std::string, std::string>> args;
|
std::vector<std::pair<std::string, std::string>> args;
|
||||||
std::unique_ptr<ObjFunction> obj{ObjFunction::Create("reg:tweedie", &ctx)};
|
std::unique_ptr<ObjFunction> obj{ObjFunction::Create("reg:tweedie", &ctx)};
|
||||||
|
|
||||||
@ -280,7 +280,7 @@ TEST(Objective, DeclareUnifiedTest(TweedieRegressionGPair)) {
|
|||||||
|
|
||||||
#if defined(__CUDACC__)
|
#if defined(__CUDACC__)
|
||||||
TEST(Objective, CPU_vs_CUDA) {
|
TEST(Objective, CPU_vs_CUDA) {
|
||||||
Context ctx = MakeCUDACtx(GetGPUId());
|
Context ctx = MakeCUDACtx(GPUIDX);
|
||||||
|
|
||||||
ObjFunction* obj = ObjFunction::Create("reg:squarederror", &ctx);
|
ObjFunction* obj = ObjFunction::Create("reg:squarederror", &ctx);
|
||||||
HostDeviceVector<GradientPair> cpu_out_preds;
|
HostDeviceVector<GradientPair> cpu_out_preds;
|
||||||
@ -331,7 +331,7 @@ TEST(Objective, CPU_vs_CUDA) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
TEST(Objective, DeclareUnifiedTest(TweedieRegressionBasic)) {
|
TEST(Objective, DeclareUnifiedTest(TweedieRegressionBasic)) {
|
||||||
Context ctx = MakeCUDACtx(GetGPUId());
|
Context ctx = MakeCUDACtx(GPUIDX);
|
||||||
std::vector<std::pair<std::string, std::string>> args;
|
std::vector<std::pair<std::string, std::string>> args;
|
||||||
std::unique_ptr<ObjFunction> obj{ObjFunction::Create("reg:tweedie", &ctx)};
|
std::unique_ptr<ObjFunction> obj{ObjFunction::Create("reg:tweedie", &ctx)};
|
||||||
|
|
||||||
@ -360,7 +360,7 @@ TEST(Objective, DeclareUnifiedTest(TweedieRegressionBasic)) {
|
|||||||
// CoxRegression not implemented in GPU code, no need for testing.
|
// CoxRegression not implemented in GPU code, no need for testing.
|
||||||
#if !defined(__CUDACC__)
|
#if !defined(__CUDACC__)
|
||||||
TEST(Objective, CoxRegressionGPair) {
|
TEST(Objective, CoxRegressionGPair) {
|
||||||
Context ctx = MakeCUDACtx(GetGPUId());
|
Context ctx = MakeCUDACtx(GPUIDX);
|
||||||
std::vector<std::pair<std::string, std::string>> args;
|
std::vector<std::pair<std::string, std::string>> args;
|
||||||
std::unique_ptr<ObjFunction> obj{ObjFunction::Create("survival:cox", &ctx)};
|
std::unique_ptr<ObjFunction> obj{ObjFunction::Create("survival:cox", &ctx)};
|
||||||
|
|
||||||
@ -375,7 +375,7 @@ TEST(Objective, CoxRegressionGPair) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
TEST(Objective, DeclareUnifiedTest(AbsoluteError)) {
|
TEST(Objective, DeclareUnifiedTest(AbsoluteError)) {
|
||||||
Context ctx = MakeCUDACtx(GetGPUId());
|
Context ctx = MakeCUDACtx(GPUIDX);
|
||||||
std::unique_ptr<ObjFunction> obj{ObjFunction::Create("reg:absoluteerror", &ctx)};
|
std::unique_ptr<ObjFunction> obj{ObjFunction::Create("reg:absoluteerror", &ctx)};
|
||||||
obj->Configure({});
|
obj->Configure({});
|
||||||
CheckConfigReload(obj, "reg:absoluteerror");
|
CheckConfigReload(obj, "reg:absoluteerror");
|
||||||
@ -419,7 +419,7 @@ TEST(Objective, DeclareUnifiedTest(AbsoluteError)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(Objective, DeclareUnifiedTest(AbsoluteErrorLeaf)) {
|
TEST(Objective, DeclareUnifiedTest(AbsoluteErrorLeaf)) {
|
||||||
Context ctx = MakeCUDACtx(GetGPUId());
|
Context ctx = MakeCUDACtx(GPUIDX);
|
||||||
bst_target_t constexpr kTargets = 3, kRows = 16;
|
bst_target_t constexpr kTargets = 3, kRows = 16;
|
||||||
std::unique_ptr<ObjFunction> obj{ObjFunction::Create("reg:absoluteerror", &ctx)};
|
std::unique_ptr<ObjFunction> obj{ObjFunction::Create("reg:absoluteerror", &ctx)};
|
||||||
obj->Configure({});
|
obj->Configure({});
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
namespace xgboost {
|
namespace xgboost {
|
||||||
TEST(Plugin, ExampleObjective) {
|
TEST(Plugin, ExampleObjective) {
|
||||||
xgboost::Context ctx = MakeCUDACtx(GetGPUId());
|
xgboost::Context ctx = MakeCUDACtx(GPUIDX);
|
||||||
auto* obj = xgboost::ObjFunction::Create("mylogistic", &ctx);
|
auto* obj = xgboost::ObjFunction::Create("mylogistic", &ctx);
|
||||||
ASSERT_EQ(obj->DefaultEvalMetric(), std::string{"logloss"});
|
ASSERT_EQ(obj->DefaultEvalMetric(), std::string{"logloss"});
|
||||||
delete obj;
|
delete obj;
|
||||||
|
|||||||
@ -27,7 +27,7 @@ namespace {
|
|||||||
void VerifyAllReduceSum() {
|
void VerifyAllReduceSum() {
|
||||||
auto const world_size = collective::GetWorldSize();
|
auto const world_size = collective::GetWorldSize();
|
||||||
auto const rank = collective::GetRank();
|
auto const rank = collective::GetRank();
|
||||||
auto const device = GetGPUId();
|
auto const device = GPUIDX;
|
||||||
int count = 3;
|
int count = 3;
|
||||||
common::SetDevice(device);
|
common::SetDevice(device);
|
||||||
thrust::device_vector<double> buffer(count, 0);
|
thrust::device_vector<double> buffer(count, 0);
|
||||||
@ -49,7 +49,7 @@ namespace {
|
|||||||
void VerifyAllGatherV() {
|
void VerifyAllGatherV() {
|
||||||
auto const world_size = collective::GetWorldSize();
|
auto const world_size = collective::GetWorldSize();
|
||||||
auto const rank = collective::GetRank();
|
auto const rank = collective::GetRank();
|
||||||
auto const device = GetGPUId();
|
auto const device = GPUIDX;
|
||||||
int const count = rank + 2;
|
int const count = rank + 2;
|
||||||
common::SetDevice(device);
|
common::SetDevice(device);
|
||||||
thrust::device_vector<char> buffer(count, 0);
|
thrust::device_vector<char> buffer(count, 0);
|
||||||
|
|||||||
@ -60,7 +60,7 @@ void VerifyBasicColumnSplit(std::array<std::vector<float>, 32> const& expected_r
|
|||||||
auto const world_size = collective::GetWorldSize();
|
auto const world_size = collective::GetWorldSize();
|
||||||
auto const rank = collective::GetRank();
|
auto const rank = collective::GetRank();
|
||||||
|
|
||||||
auto ctx = MakeCUDACtx(GetGPUId());
|
auto ctx = MakeCUDACtx(GPUIDX);
|
||||||
std::unique_ptr<Predictor> predictor =
|
std::unique_ptr<Predictor> predictor =
|
||||||
std::unique_ptr<Predictor>(Predictor::Create("gpu_predictor", &ctx));
|
std::unique_ptr<Predictor>(Predictor::Create("gpu_predictor", &ctx));
|
||||||
predictor->Configure({});
|
predictor->Configure({});
|
||||||
@ -283,7 +283,7 @@ TEST(GPUPredictor, CategoricalPredictLeaf) {
|
|||||||
TEST(GPUPredictor, PredictLeafBasic) {
|
TEST(GPUPredictor, PredictLeafBasic) {
|
||||||
size_t constexpr kRows = 5, kCols = 5;
|
size_t constexpr kRows = 5, kCols = 5;
|
||||||
auto dmat = RandomDataGenerator(kRows, kCols, 0).Device(0).GenerateDMatrix();
|
auto dmat = RandomDataGenerator(kRows, kCols, 0).Device(0).GenerateDMatrix();
|
||||||
auto lparam = MakeCUDACtx(GetGPUId());
|
auto lparam = MakeCUDACtx(GPUIDX);
|
||||||
std::unique_ptr<Predictor> gpu_predictor =
|
std::unique_ptr<Predictor> gpu_predictor =
|
||||||
std::unique_ptr<Predictor>(Predictor::Create("gpu_predictor", &lparam));
|
std::unique_ptr<Predictor>(Predictor::Create("gpu_predictor", &lparam));
|
||||||
gpu_predictor->Configure({});
|
gpu_predictor->Configure({});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user