Internal: Extract device pointer from various formats. Args: device_array: Device array (int pointer, __cuda_array_interface__, or dict) Returns: int: Device pointer address
(device_array: int | dict | object)
| 76 | |
| 77 | |
| 78 | def _get_device_ptr(device_array: int | dict | object) -> int: |
| 79 | """ |
| 80 | Internal: Extract device pointer from various formats. |
| 81 | |
| 82 | Args: |
| 83 | device_array: Device array (int pointer, __cuda_array_interface__, or dict) |
| 84 | |
| 85 | Returns: |
| 86 | int: Device pointer address |
| 87 | """ |
| 88 | if isinstance(device_array, int): |
| 89 | return device_array |
| 90 | elif hasattr(device_array, "__cuda_array_interface__"): |
| 91 | return device_array.__cuda_array_interface__["data"][0] |
| 92 | elif isinstance(device_array, dict) and "data" in device_array: |
| 93 | return device_array["data"][0] |
| 94 | else: |
| 95 | err_msg = "Invalid device array: " |
| 96 | err_msg += "must be int pointer, " |
| 97 | err_msg += "have __cuda_array_interface__, or " |
| 98 | err_msg += "be a dict with 'data' key" |
| 99 | raise ValueError(err_msg) |
| 100 | |
| 101 | |
| 102 | def cuda_memcpy_h2d( |
no outgoing calls
no test coverage detected