| 64 | } |
| 65 | |
| 66 | void RunTest(Context* ctx, std::string const& updater_name, std::string const& strategy) { |
| 67 | { |
| 68 | ctx->InitAllowUnknown(Args{{"nthread", "8"}}); |
| 69 | |
| 70 | ObjInfo task{ObjInfo::kRegression}; |
| 71 | std::unique_ptr<TreeUpdater> updater{TreeUpdater::Create(updater_name, ctx, &task)}; |
| 72 | RegTree tree; |
| 73 | std::vector<RegTree*> trees{&tree}; |
| 74 | auto gpair = GenerateRandomGradients(ctx, n_samples_, 1); |
| 75 | tree::TrainParam param; |
| 76 | param.UpdateAllowUnknown(Args{{"max_bin", "64"}}); |
| 77 | |
| 78 | updater->Configure(Args{}); |
| 79 | std::vector<HostDeviceVector<bst_node_t>> position(1); |
| 80 | updater->Update(¶m, &gpair, Xy_.get(), position, trees); |
| 81 | HostDeviceVector<float> out_prediction_cached; |
| 82 | out_prediction_cached.SetDevice(ctx->Device()); |
| 83 | out_prediction_cached.Resize(n_samples_); |
| 84 | auto cache = |
| 85 | linalg::MakeTensorView(ctx, &out_prediction_cached, out_prediction_cached.Size(), 1); |
| 86 | ASSERT_TRUE(updater->UpdatePredictionCache(Xy_.get(), common::Span{position}, cache)); |
| 87 | } |
| 88 | |
| 89 | for (auto policy : {"depthwise", "lossguide"}) { |
| 90 | for (auto subsample : {1.0f, 0.4f}) { |
| 91 | this->RunLearnerTest(ctx, updater_name, subsample, policy, strategy); |
| 92 | this->RunLearnerTest(ctx, updater_name, subsample, policy, strategy); |
| 93 | } |
| 94 | } |
| 95 | } |
| 96 | }; |
| 97 | } // namespace xgboost |
nothing calls this directly
no test coverage detected