Implement extend method for meta info. (#5800)

* Implement extend for host device vector.
This commit is contained in:
Jiaming Yuan
2020-06-20 03:32:03 +08:00
committed by GitHub
parent a6d9a06b7b
commit c4d721200a
7 changed files with 138 additions and 1 deletions

View File

@@ -77,7 +77,6 @@ TEST(MetaInfo, FromInterface) {
TEST(MetaInfo, Group) {
cudaSetDevice(0);
MetaInfo info;
thrust::device_vector<uint32_t> d_uint;
@@ -105,4 +104,25 @@ TEST(MetaInfo, Group) {
info = MetaInfo();
EXPECT_ANY_THROW(info.SetInfo("group", float_str.c_str()));
}
TEST(MetaInfo, DeviceExtend) {
dh::safe_cuda(cudaSetDevice(0));
size_t const kRows = 100;
MetaInfo lhs, rhs;
thrust::device_vector<float> d_data;
std::string str = PrepareData<float>("<f4", &d_data, kRows);
lhs.SetInfo("label", str.c_str());
rhs.SetInfo("label", str.c_str());
ASSERT_FALSE(rhs.labels_.HostCanRead());
lhs.num_row_ = kRows;
rhs.num_row_ = kRows;
lhs.Extend(rhs, true);
ASSERT_EQ(lhs.num_row_, kRows * 2);
ASSERT_FALSE(lhs.labels_.HostCanRead());
ASSERT_FALSE(lhs.labels_.HostCanRead());
ASSERT_FALSE(rhs.labels_.HostCanRead());
}
} // namespace xgboost