Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
make code_type public
  • Loading branch information
leofang committed Oct 6, 2025
commit 727ead575ec530c6f935a2dbabe8629d979a2d88
5 changes: 5 additions & 0 deletions cuda_core/cuda/core/experimental/_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,11 @@ def name(self) -> str:
"""Return a human-readable name of this code object."""
return self._name

@property
def code_type(self) -> str:
"""Return the type of the underlying code object."""
return self._code_type

@property
@precondition(_lazy_load_module)
def handle(self):
Expand Down
1 change: 1 addition & 0 deletions cuda_core/docs/source/release/0.X.Y-notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ New features
- CUDA 13.x testing support through new ``test-cu13`` dependency group.
- Stream-ordered memory allocation can now be shared on Linux via :class:`DeviceMemoryResource`.
- Added NVVM IR support to :class:`Program`. NVVM IR is now understood with ``code_type="nvvm"``.
- Added an :attr:`ObjectCode.code_type` attribute for querying the code type.


New examples
Expand Down
8 changes: 4 additions & 4 deletions cuda_core/tests/test_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def test_object_code_load_ptx_from_file(get_saxpy_kernel_ptx, tmp_path):
ptx_file.write_bytes(ptx)
mod_obj = ObjectCode.from_ptx(str(ptx_file), symbol_mapping=sym_map)
assert mod_obj.code == str(ptx_file)
assert mod_obj._code_type == "ptx"
assert mod_obj.code_type == "ptx"
if not Program._can_load_generated_ptx():
pytest.skip("PTX version too new for current driver")
mod_obj.get_kernel("saxpy<double>") # force loading
Expand Down Expand Up @@ -198,7 +198,7 @@ def test_object_code_load_ltoir(get_saxpy_kernel_ltoir):
assert isinstance(ltoir, bytes)
mod_obj = ObjectCode.from_ltoir(ltoir, symbol_mapping=sym_map)
assert mod_obj.code == ltoir
assert mod_obj._code_type == "ltoir"
assert mod_obj.code_type == "ltoir"
# ltoir doesn't support kernel retrieval directly as it's used for linking
assert mod_obj._handle is None
# Test that get_kernel fails for unsupported code type
Expand All @@ -215,7 +215,7 @@ def test_object_code_load_ltoir_from_file(get_saxpy_kernel_ltoir, tmp_path):
ltoir_file.write_bytes(ltoir)
mod_obj = ObjectCode.from_ltoir(str(ltoir_file), symbol_mapping=sym_map)
assert mod_obj.code == str(ltoir_file)
assert mod_obj._code_type == "ltoir"
assert mod_obj.code_type == "ltoir"
# ltoir doesn't support kernel retrieval directly as it's used for linking
assert mod_obj._handle is None

Expand Down Expand Up @@ -418,4 +418,4 @@ def test_module_serialization_roundtrip(get_saxpy_kernel_cubin):
assert isinstance(result, ObjectCode)
assert objcode.code == result.code
assert objcode._sym_map == result._sym_map
assert objcode._code_type == result._code_type
assert objcode.code_type == result.code_type