Fix IsDense. (#5702)
This commit is contained in:
@@ -129,3 +129,22 @@ TEST(DeviceDMatrix, Equivalent) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST(DeviceDMatrix, IsDense) {
|
||||
int num_bins = 16;
|
||||
auto test = [num_bins] (float sparsity) {
|
||||
HostDeviceVector<float> data;
|
||||
std::string interface_str = RandomDataGenerator{10, 10, sparsity}
|
||||
.Device(0).GenerateArrayInterface(&data);
|
||||
data::CupyAdapter x{interface_str};
|
||||
std::unique_ptr<data::DeviceDMatrix> device_dmat{ new data::DeviceDMatrix(
|
||||
&x, std::numeric_limits<float>::quiet_NaN(), 1, num_bins) };
|
||||
if (sparsity == 0.0) {
|
||||
ASSERT_TRUE(device_dmat->IsDense()) << sparsity;
|
||||
} else {
|
||||
ASSERT_FALSE(device_dmat->IsDense());
|
||||
}
|
||||
};
|
||||
test(0.0);
|
||||
test(0.1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user