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

Function TEST

tests/cpp/common/test_column_matrix.cc:24–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22
23namespace xgboost::common {
24TEST(ColumnMatrix, Basic) {
25 int32_t max_num_bins[] = {static_cast<int32_t>(std::numeric_limits<uint8_t>::max()) + 1,
26 static_cast<int32_t>(std::numeric_limits<uint16_t>::max()) + 1,
27 static_cast<int32_t>(std::numeric_limits<uint16_t>::max()) + 2};
28 Context ctx;
29 BinTypeSize last{kUint8BinsTypeSize};
30 for (int32_t max_num_bin : max_num_bins) {
31 auto dmat = RandomDataGenerator(100, 10, 0.0).GenerateDMatrix();
32 auto sparse_thresh = 0.2;
33 GHistIndexMatrix gmat{&ctx, dmat.get(), max_num_bin, sparse_thresh, false};
34 ColumnMatrix column_matrix;
35 for (auto const& page : dmat->GetBatches<SparsePage>()) {
36 column_matrix.InitFromSparse(page, gmat, sparse_thresh, ctx.Threads());
37 }
38 ASSERT_GE(column_matrix.GetTypeSize(), last);
39 ASSERT_LE(column_matrix.GetTypeSize(), kUint32BinsTypeSize);
40 last = column_matrix.GetTypeSize();
41 ASSERT_FALSE(column_matrix.AnyMissing());
42 for (auto i = 0ull; i < dmat->Info().num_row_; i++) {
43 for (auto j = 0ull; j < dmat->Info().num_col_; j++) {
44 DispatchBinType(column_matrix.GetTypeSize(), [&](auto dtype) {
45 using T = decltype(dtype);
46 auto col = column_matrix.DenseColumn<T, false>(j);
47 ASSERT_EQ(gmat.index[i * dmat->Info().num_col_ + j], col.GetGlobalBinIdx(i));
48 });
49 }
50 }
51 }
52}
53
54template <typename BinIdxType>
55void CheckSparseColumn(SparseColumnIter<BinIdxType>* p_col, const GHistIndexMatrix& gmat) {

Callers

nothing calls this directly

Calls 14

RandomDataGeneratorClass · 0.85
DispatchBinTypeFunction · 0.85
CheckSparseColumnFunction · 0.85
GenerateDMatrixMethod · 0.80
InitFromSparseMethod · 0.80
ThreadsMethod · 0.80
GetTypeSizeMethod · 0.80
AnyMissingMethod · 0.80
GetGlobalBinIdxMethod · 0.80
getMethod · 0.45
InfoMethod · 0.45

Tested by

no test coverage detected