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

Function GetArrayInterface

tests/cpp/helpers.h:212–231  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

210
211template <typename T>
212Json GetArrayInterface(HostDeviceVector<T> const* storage, size_t rows, size_t cols) {
213 Json array_interface{Object()};
214 array_interface["data"] = std::vector<Json>(2);
215 if (storage->DeviceCanRead()) {
216 array_interface["data"][0] = Integer{reinterpret_cast<int64_t>(storage->ConstDevicePointer())};
217 array_interface["stream"] = nullptr;
218 } else {
219 array_interface["data"][0] = Integer{reinterpret_cast<int64_t>(storage->ConstHostPointer())};
220 }
221 array_interface["data"][1] = Boolean(false);
222
223 array_interface["shape"] = std::vector<Json>(2);
224 array_interface["shape"][0] = rows;
225 array_interface["shape"][1] = cols;
226
227 char t = linalg::detail::ArrayInterfaceHandler::TypeChar<T>();
228 array_interface["typestr"] = String(std::string{"<"} + t + std::to_string(sizeof(T)));
229 array_interface["version"] = 3;
230 return array_interface;
231}
232
233// Generate in-memory random data without using DMatrix.
234class RandomDataGenerator {

Callers 11

ArrayInterfaceImplMethod · 0.85
GenerateDMatrixMethod · 0.85
TESTFunction · 0.85
TESTFunction · 0.85
MakeLabelForTestFunction · 0.85
TESTFunction · 0.85
TESTFunction · 0.85
TestSparsePredictionFunction · 0.85
TestVectorLeafPredictionFunction · 0.85
TESTFunction · 0.85

Calls 3

ConstHostPointerMethod · 0.80
DeviceCanReadMethod · 0.45
ConstDevicePointerMethod · 0.45

Tested by 9

TESTFunction · 0.68
TESTFunction · 0.68
MakeLabelForTestFunction · 0.68
TESTFunction · 0.68
TESTFunction · 0.68
TestSparsePredictionFunction · 0.68
TestVectorLeafPredictionFunction · 0.68
TESTFunction · 0.68