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

Method ArrayInterfaceStr

src/data/metainfo.cc:20–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18
19namespace xgboost {
20std::string TypedArrayRef::ArrayInterfaceStr() const {
21 return data::DispatchDType(this->dtype, [this](auto dtype) {
22 using DType = decltype(dtype);
23 auto ptr = static_cast<std::add_pointer_t<std::add_const_t<DType>>>(this->data);
24 if (this->ndim == 1) {
25 auto vec = linalg::MakeVec(ptr, this->shape.front());
26 return linalg::ArrayInterfaceStr(vec);
27 } else {
28 auto n = this->Size();
29 if (ptr) {
30 CHECK_GT(n, 0);
31 }
32 if (n > 0) {
33 CHECK(ptr);
34 }
35 auto mat = linalg::MakeTensorView(DeviceOrd::CPU(), common::Span{ptr, n}, this->shape[0],
36 this->shape[1]);
37 return linalg::ArrayInterfaceStr(mat);
38 }
39 });
40}
41} // namespace xgboost
42
43namespace xgboost::data {

Callers 1

XGDMatrixGetInfoRefFunction · 0.80

Calls 6

SizeMethod · 0.95
MakeVecFunction · 0.85
ArrayInterfaceStrFunction · 0.85
MakeTensorViewFunction · 0.85
CPUFunction · 0.85
DispatchDTypeFunction · 0.70

Tested by

no test coverage detected