Skip to content

Commit e76b1c5

Browse files
Add public handle to object code (#492)
1 parent 079e177 commit e76b1c5

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

cuda_core/cuda/core/experimental/_module.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,3 +350,9 @@ def get_kernel(self, name) -> Kernel:
350350
def code(self) -> CodeTypeT:
351351
"""Return the underlying code object."""
352352
return self._module
353+
354+
@property
355+
@precondition(_lazy_load_module)
356+
def handle(self):
357+
"""Return the underlying handle object."""
358+
return self._handle

cuda_core/tests/test_module.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,16 @@ def get_saxpy_kernel_ptx(init_cuda):
6868
return ptx, mod
6969

7070

71+
@pytest.fixture(scope="function")
72+
def get_saxpy_object_code(init_cuda):
73+
prog = Program(SAXPY_KERNEL, code_type="c++")
74+
mod = prog.compile(
75+
"cubin",
76+
name_expressions=("saxpy<float>", "saxpy<double>"),
77+
)
78+
return mod
79+
80+
7181
def test_get_kernel(init_cuda):
7282
kernel = """extern "C" __global__ void ABC() { }"""
7383

@@ -147,3 +157,8 @@ def test_object_code_load_cubin_from_file(get_saxpy_kernel, tmp_path):
147157
mod = ObjectCode.from_cubin(str(cubin_file), symbol_mapping=sym_map)
148158
assert mod.code == str(cubin_file)
149159
mod.get_kernel("saxpy<double>") # force loading
160+
161+
162+
def test_object_code_handle(get_saxpy_object_code):
163+
mod = get_saxpy_object_code
164+
assert mod.handle is not None

0 commit comments

Comments
 (0)