Skip to content

Commit 727ead5

Browse files
committed
make code_type public
1 parent 3665e41 commit 727ead5

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

cuda_core/cuda/core/experimental/_module.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,11 @@ def name(self) -> str:
666666
"""Return a human-readable name of this code object."""
667667
return self._name
668668

669+
@property
670+
def code_type(self) -> str:
671+
"""Return the type of the underlying code object."""
672+
return self._code_type
673+
669674
@property
670675
@precondition(_lazy_load_module)
671676
def handle(self):

cuda_core/docs/source/release/0.X.Y-notes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ New features
3232
- CUDA 13.x testing support through new ``test-cu13`` dependency group.
3333
- Stream-ordered memory allocation can now be shared on Linux via :class:`DeviceMemoryResource`.
3434
- Added NVVM IR support to :class:`Program`. NVVM IR is now understood with ``code_type="nvvm"``.
35+
- Added an :attr:`ObjectCode.code_type` attribute for querying the code type.
3536

3637

3738
New examples

cuda_core/tests/test_module.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def test_object_code_load_ptx_from_file(get_saxpy_kernel_ptx, tmp_path):
158158
ptx_file.write_bytes(ptx)
159159
mod_obj = ObjectCode.from_ptx(str(ptx_file), symbol_mapping=sym_map)
160160
assert mod_obj.code == str(ptx_file)
161-
assert mod_obj._code_type == "ptx"
161+
assert mod_obj.code_type == "ptx"
162162
if not Program._can_load_generated_ptx():
163163
pytest.skip("PTX version too new for current driver")
164164
mod_obj.get_kernel("saxpy<double>") # force loading
@@ -198,7 +198,7 @@ def test_object_code_load_ltoir(get_saxpy_kernel_ltoir):
198198
assert isinstance(ltoir, bytes)
199199
mod_obj = ObjectCode.from_ltoir(ltoir, symbol_mapping=sym_map)
200200
assert mod_obj.code == ltoir
201-
assert mod_obj._code_type == "ltoir"
201+
assert mod_obj.code_type == "ltoir"
202202
# ltoir doesn't support kernel retrieval directly as it's used for linking
203203
assert mod_obj._handle is None
204204
# Test that get_kernel fails for unsupported code type
@@ -215,7 +215,7 @@ def test_object_code_load_ltoir_from_file(get_saxpy_kernel_ltoir, tmp_path):
215215
ltoir_file.write_bytes(ltoir)
216216
mod_obj = ObjectCode.from_ltoir(str(ltoir_file), symbol_mapping=sym_map)
217217
assert mod_obj.code == str(ltoir_file)
218-
assert mod_obj._code_type == "ltoir"
218+
assert mod_obj.code_type == "ltoir"
219219
# ltoir doesn't support kernel retrieval directly as it's used for linking
220220
assert mod_obj._handle is None
221221

@@ -418,4 +418,4 @@ def test_module_serialization_roundtrip(get_saxpy_kernel_cubin):
418418
assert isinstance(result, ObjectCode)
419419
assert objcode.code == result.code
420420
assert objcode._sym_map == result._sym_map
421-
assert objcode._code_type == result._code_type
421+
assert objcode.code_type == result.code_type

0 commit comments

Comments
 (0)