File tree Expand file tree Collapse file tree
cuda_bindings/cuda/bindings/utils Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22# SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
33
4- from ._get_handle import get_cuda_native_handle
4+ from typing import Any , Callable
5+
56from ._ptx_utils import get_minimal_required_cuda_ver_from_ptx_ver , get_ptx_ver
7+
8+ _handle_getters : dict [type , Callable [[Any ], int ]] = {}
9+
10+
11+ def _add_cuda_native_handle_getter (t : type , getter : Callable [[Any ], int ]) -> None :
12+ _handle_getters [t ] = getter
13+
14+
15+ def get_cuda_native_handle (obj : Any ) -> int :
16+ """Returns the address of the provided CUDA Python object as a Python int.
17+
18+ Parameters
19+ ----------
20+ obj : Any
21+ CUDA Python object
22+
23+ Returns
24+ -------
25+ int : The object address.
26+ """
27+ obj_type = type (obj )
28+ try :
29+ return _handle_getters [obj_type ](obj )
30+ except KeyError :
31+ raise TypeError ("Unknown type: " + str (obj_type )) from None
Load diff This file was deleted.
You can’t perform that action at this time.
0 commit comments