Initialize DMatrix from cupy ndarray.
(
data: DataType,
missing: FloatCompatible,
nthread: int,
feature_names: Optional[FeatureNames],
feature_types: Optional[FeatureTypes],
)
| 1182 | |
| 1183 | |
| 1184 | def _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 | |
| 1204 | def _is_cupy_csr(data: DataType) -> bool: |
no test coverage detected