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

Function cuda_array_interface_dict

python-package/xgboost/_data_utils.py:96–113  ·  view source on GitHub ↗

Returns a dictionary storing the CUDA array interface.

(data: _CudaArrayLikeArg)

Source from the content-addressed store, hash-verified

94
95
96def cuda_array_interface_dict(data: _CudaArrayLikeArg) -> CudaArrayInf:
97 """Returns a dictionary storing the CUDA array interface."""
98 if array_hasobject(data):
99 raise ValueError("Input data contains `object` dtype. Expecting numeric data.")
100 ainf = data.__cuda_array_interface__
101 if "mask" in ainf and ainf["mask"] is not None:
102 mask_ainf = ainf["mask"].__cuda_array_interface__ # type: ignore[union-attr]
103 # Normalize the validity mask to XGBoost's expected layout (`|t1` bit field of
104 # length `n_samples`).
105 typestr = mask_ainf["typestr"]
106 n_samples = ainf["shape"][0]
107 if typestr[1] in ("u", "i", "t") and typestr[2:] == "1" and n_samples:
108 mask_ainf = dict(mask_ainf)
109 mask_ainf["typestr"] = "|t1"
110 mask_ainf["shape"] = (n_samples,)
111 mask_ainf.pop("strides", None)
112 ainf["mask"] = mask_ainf
113 return ainf
114
115
116def cuda_array_interface(data: _CudaArrayLikeArg) -> bytes:

Callers 3

push_seriesMethod · 0.85
cuda_array_interfaceFunction · 0.85
cudf_cat_infFunction · 0.85

Calls 1

array_hasobjectFunction · 0.85

Tested by

no test coverage detected