Skip to content

Commit 0382a28

Browse files
[doc-only] Add missing docstrings for new APIs
- Add ProgramOptions.extra_sources and use_libdevice to class docstring - Add docstrings to StridedMemoryView.from_cuda_array_interface, from_array_interface, and from_any_interface - Add LEGACY_DEFAULT_STREAM and PER_THREAD_DEFAULT_STREAM to api.rst Co-authored-by: Cursor <[email protected]>
1 parent 773f6f8 commit 0382a28

3 files changed

Lines changed: 38 additions & 0 deletions

File tree

‎cuda_core/cuda/core/_memoryview.pyx‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,18 +158,45 @@ cdef class StridedMemoryView:
158158

159159
@classmethod
160160
def from_cuda_array_interface(cls, obj: object, stream_ptr: int | None=None) -> StridedMemoryView:
161+
"""Create a view from an object supporting the ``__cuda_array_interface__`` protocol.
162+
163+
Parameters
164+
----------
165+
obj : object
166+
An object implementing the ``__cuda_array_interface__`` protocol.
167+
stream_ptr : int, optional
168+
Stream pointer for synchronization. If ``None``, no synchronization is performed.
169+
"""
161170
cdef StridedMemoryView buf = StridedMemoryView.__new__(cls)
162171
view_as_cai(obj, stream_ptr, buf)
163172
return buf
164173

165174
@classmethod
166175
def from_array_interface(cls, obj: object) -> StridedMemoryView:
176+
"""Create a view from an object supporting the ``__array_interface__`` protocol.
177+
178+
Parameters
179+
----------
180+
obj : object
181+
An object implementing the ``__array_interface__`` protocol (e.g., a numpy array).
182+
"""
167183
cdef StridedMemoryView buf = StridedMemoryView.__new__(cls)
168184
view_as_array_interface(obj, buf)
169185
return buf
170186

171187
@classmethod
172188
def from_any_interface(cls, obj: object, stream_ptr: int | None = None) -> StridedMemoryView:
189+
"""Create a view by automatically selecting the best available protocol.
190+
191+
Tries DLPack first, then falls back to ``__cuda_array_interface__``.
192+
193+
Parameters
194+
----------
195+
obj : object
196+
An object implementing DLPack or ``__cuda_array_interface__``.
197+
stream_ptr : int, optional
198+
Stream pointer for synchronization. If ``None``, no synchronization is performed.
199+
"""
173200
if check_has_dlpack(obj):
174201
return cls.from_dlpack(obj, stream_ptr)
175202
return cls.from_cuda_array_interface(obj, stream_ptr)

‎cuda_core/cuda/core/_program.pyx‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,15 @@ class ProgramOptions:
304304
instantiate_templates_in_pch : bool, optional
305305
Control template instantiation in PCH (NVRTC only, CUDA 12.8+).
306306
Default: False
307+
extra_sources : list of 2-tuples or tuple of 2-tuples, optional
308+
Additional NVVM IR modules to compile together with the main program, specified as
309+
``((name1, source1), (name2, source2), ...)``. Each source can be a string (textual
310+
LLVM IR), bytes, or bytearray. Only supported for the NVVM backend.
311+
Default: None
312+
use_libdevice : bool, optional
313+
Load NVIDIA's libdevice math builtins library during NVVM compilation. Only
314+
supported for the NVVM backend.
315+
Default: False
307316
"""
308317

309318
name: str | None = "default_program"

‎cuda_core/docs/source/api.rst‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ CUDA runtime
2323
Graph
2424
GraphBuilder
2525
launch
26+
LEGACY_DEFAULT_STREAM
27+
PER_THREAD_DEFAULT_STREAM
2628

2729
:template: autosummary/cyclass.rst
2830

0 commit comments

Comments
 (0)