MCPcopy Create free account
hub / github.com/CVCUDA/CV-CUDA / _get_device_ptr

Function _get_device_ptr

samples/common.py:78–99  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

76
77
78def _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
102def cuda_memcpy_h2d(

Callers 2

cuda_memcpy_h2dFunction · 0.85
cuda_memcpy_d2hFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected