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

Function _from_cupy_array

python-package/xgboost/data.py:1184–1201  ·  view source on GitHub ↗

Initialize DMatrix from cupy ndarray.

(
    data: DataType,
    missing: FloatCompatible,
    nthread: int,
    feature_names: Optional[FeatureNames],
    feature_types: Optional[FeatureTypes],
)

Source from the content-addressed store, hash-verified

1182
1183
1184def _from_cupy_array(
1185 data: DataType,
1186 missing: FloatCompatible,
1187 nthread: int,
1188 feature_names: Optional[FeatureNames],
1189 feature_types: Optional[FeatureTypes],
1190) -> DispatchedDataBackendReturnType:
1191 """Initialize DMatrix from cupy ndarray."""
1192 data = _transform_cupy_array(data)
1193 interface_str = cuda_array_interface(data)
1194 handle = ctypes.c_void_p()
1195 config = bytes(json.dumps({"missing": missing, "nthread": nthread}), "utf-8")
1196 _check_call(
1197 _LIB.XGDMatrixCreateFromCudaArrayInterface(
1198 interface_str, config, ctypes.byref(handle)
1199 )
1200 )
1201 return handle, feature_names, feature_types
1202
1203
1204def _is_cupy_csr(data: DataType) -> bool:

Callers 2

_from_dlpackFunction · 0.85
dispatch_data_backendFunction · 0.85

Calls 3

_transform_cupy_arrayFunction · 0.85
cuda_array_interfaceFunction · 0.85
_check_callFunction · 0.85

Tested by

no test coverage detected