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

Function TEST

tests/cpp/data/test_array_interface.cc:12–31  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10
11namespace xgboost {
12TEST(ArrayInterface, Initialize) {
13 size_t constexpr kRows = 10, kCols = 10;
14 HostDeviceVector<float> storage;
15 auto array = RandomDataGenerator{kRows, kCols, 0}.GenerateArrayInterface(&storage);
16 auto arr_interface = ArrayInterface<2>(StringView{array});
17 ASSERT_EQ(arr_interface.Shape<0>(), kRows);
18 ASSERT_EQ(arr_interface.Shape<1>(), kCols);
19 ASSERT_EQ(arr_interface.data, storage.ConstHostPointer());
20 ASSERT_EQ(arr_interface.ElementSize(), 4);
21 ASSERT_EQ(arr_interface.type, ArrayInterfaceHandler::kF4);
22
23 HostDeviceVector<size_t> u64_storage(storage.Size());
24 std::string u64_arr_str{ArrayInterfaceStr(linalg::TensorView<size_t const, 2>{
25 u64_storage.ConstHostSpan(), {kRows, kCols}, DeviceOrd::CPU()})};
26 std::copy(storage.ConstHostVector().cbegin(), storage.ConstHostVector().cend(),
27 u64_storage.HostSpan().begin());
28 auto u64_arr = ArrayInterface<2>{u64_arr_str};
29 ASSERT_EQ(u64_arr.ElementSize(), 8);
30 ASSERT_EQ(u64_arr.type, ArrayInterfaceHandler::kU8);
31}
32
33TEST(ArrayInterface, Error) {
34 constexpr size_t kRows = 16, kCols = 10;

Callers

nothing calls this directly

Calls 14

ArrayInterfaceStrFunction · 0.85
CPUFunction · 0.85
ArrayClass · 0.85
array_interfaceFunction · 0.85
swapFunction · 0.85
ConstHostPointerMethod · 0.80
ConstHostSpanMethod · 0.80
HostSpanMethod · 0.80
JsonClass · 0.50
SizeMethod · 0.45
cbeginMethod · 0.45

Tested by

no test coverage detected