MCPcopy Create free account
hub / github.com/dmlc/xgboost / Run

Method Run

tests/cpp/data/test_gradient_index.cc:164–199  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

162class GHistIndexMatrixTest : public testing::TestWithParam<std::tuple<float, float>> {
163 protected:
164 void Run(float density, double threshold) {
165 // Only testing with small sample size as the cuts might be different between host and
166 // device.
167 size_t n_samples{128}, n_features{13};
168 Context ctx;
169 auto Xy = RandomDataGenerator{n_samples, n_features, 1 - density}.GenerateDMatrix(true);
170 std::unique_ptr<GHistIndexMatrix> from_ellpack;
171 ASSERT_TRUE(Xy->SingleColBlock());
172 bst_bin_t constexpr kBins{17};
173 auto p = BatchParam{kBins, threshold};
174 auto gpu_ctx = MakeCUDACtx(0);
175 for (auto const &page : Xy->GetBatches<EllpackPage>(
176 &gpu_ctx, BatchParam{kBins, tree::TrainParam::DftSparseThreshold()})) {
177 from_ellpack = std::make_unique<GHistIndexMatrix>(&ctx, Xy->Info(), page, p);
178 }
179
180 for (auto const &from_sparse_page : Xy->GetBatches<GHistIndexMatrix>(&ctx, p)) {
181 ASSERT_EQ(from_sparse_page.IsDense(), from_ellpack->IsDense());
182 ASSERT_EQ(from_sparse_page.base_rowid, 0);
183 ASSERT_EQ(from_sparse_page.base_rowid, from_ellpack->base_rowid);
184 ASSERT_EQ(from_sparse_page.Size(), from_ellpack->Size());
185 ASSERT_EQ(from_sparse_page.index.Size(), from_ellpack->index.Size());
186
187 common::ValidateCuts(from_sparse_page.Cuts(), Xy.get(), kBins);
188 common::ValidateCuts(from_ellpack->Cuts(), Xy.get(), kBins);
189
190 auto const &columns_from_sparse = from_sparse_page.Transpose();
191 auto const &columns_from_ellpack = from_ellpack->Transpose();
192 ASSERT_EQ(columns_from_sparse.AnyMissing(), columns_from_ellpack.AnyMissing());
193 ASSERT_EQ(columns_from_sparse.GetTypeSize(), columns_from_ellpack.GetTypeSize());
194 ASSERT_EQ(columns_from_sparse.GetNumFeature(), columns_from_ellpack.GetNumFeature());
195 for (size_t i = 0; i < n_features; ++i) {
196 ASSERT_EQ(columns_from_sparse.GetColumnType(i), columns_from_ellpack.GetColumnType(i));
197 }
198 }
199 }
200};
201} // anonymous namespace
202

Callers 1

TEST_PFunction · 0.45

Calls 12

MakeCUDACtxFunction · 0.85
ValidateCutsFunction · 0.85
GenerateDMatrixMethod · 0.80
SingleColBlockMethod · 0.80
AnyMissingMethod · 0.80
GetTypeSizeMethod · 0.80
GetColumnTypeMethod · 0.80
InfoMethod · 0.45
IsDenseMethod · 0.45
SizeMethod · 0.45
getMethod · 0.45
GetNumFeatureMethod · 0.45

Tested by

no test coverage detected