Skip to content

add public handle to object code #492

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cuda_core/cuda/core/experimental/_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,3 +341,9 @@ def get_kernel(self, name) -> Kernel:
def code(self) -> CodeTypeT:
"""Return the underlying code object."""
return self._module

@property
@precondition(_lazy_load_module)
def handle(self):
"""Return the underlying handle object."""
return self._handle
15 changes: 15 additions & 0 deletions cuda_core/tests/test_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ def get_saxpy_kernel_ptx(init_cuda):
return ptx, mod


@pytest.fixture(scope="function")
def get_saxpy_object_code(init_cuda):
prog = Program(SAXPY_KERNEL, code_type="c++")
mod = prog.compile(
"cubin",
name_expressions=("saxpy<float>", "saxpy<double>"),
)
return mod


def test_get_kernel(init_cuda):
kernel = """extern "C" __global__ void ABC() { }"""

Expand Down Expand Up @@ -147,3 +157,8 @@ def test_object_code_load_cubin_from_file(get_saxpy_kernel, tmp_path):
mod = ObjectCode.from_cubin(str(cubin_file), symbol_mapping=sym_map)
assert mod.code == str(cubin_file)
mod.get_kernel("saxpy<double>") # force loading


def test_object_code_handle(get_saxpy_object_code):
mod = get_saxpy_object_code
assert mod.handle is not None
Loading