@@ -9,6 +9,7 @@ from collections.abc import Iterable
99from cuda .core ._device import Device
1010from cuda .core ._event import Event
1111from cuda .core ._launch_config import LaunchConfig
12+ from cuda .core ._memory ._buffer import Buffer
1213from cuda .core ._module import Kernel
1314from cuda .core ._utils .cuda_utils import driver
1415from cuda .core .graph ._adjacency_set_proxy import AdjacencySetProxy
@@ -178,13 +179,16 @@ class GraphNode:
178179 A new FreeNode representing the free operation.
179180 """
180181
181- def memset (self , dst : int , value , width : int , height : int = 1 , pitch : int = 0 ) -> MemsetNode :
182+ def memset (self , dst : Buffer | int , value , width : int , * , height : int = 1 , pitch : int = 0 , dst_owner = None ) -> MemsetNode :
182183 """Add a memset node depending on this node.
183184
184185 Parameters
185186 ----------
186- dst : int
187- Destination device pointer.
187+ dst : Buffer or int
188+ Destination. When ``dst`` is a :class:`Buffer`, the underlying
189+ allocation is retained for the graph's lifetime. A raw pointer
190+ (``int``) is used as-is; the caller must keep the underlying memory
191+ alive, or supply ``dst_owner`` to have the graph retain it.
188192 value : int or buffer-protocol object
189193 Fill value. int for 1-byte fill (range [0, 256)),
190194 or buffer-protocol object of 1, 2, or 4 bytes.
@@ -194,14 +198,23 @@ class GraphNode:
194198 Number of rows (default 1).
195199 pitch : int, optional
196200 Pitch of destination in bytes (default 0, unused if height is 1).
201+ dst_owner : object, optional
202+ Object retained for the graph's lifetime when ``dst`` is a raw
203+ pointer. A :class:`Buffer` owner retains its underlying allocation,
204+ not the wrapper. Must not be passed when ``dst`` is a :class:`Buffer`.
197205
198206 Returns
199207 -------
200208 MemsetNode
201209 A new MemsetNode representing the memset operation.
210+
211+ Raises
212+ ------
213+ ValueError
214+ If ``dst_owner`` is given together with a :class:`Buffer` ``dst``.
202215 """
203216
204- def memcpy (self , dst : int , src : int , size : int ) -> MemcpyNode :
217+ def memcpy (self , dst : Buffer | int , src : Buffer | int , size : int , * , dst_owner = None , src_owner = None ) -> MemcpyNode :
205218 """Add a memcpy node depending on this node.
206219
207220 Copies ``size`` bytes from ``src`` to ``dst``. Memory types are
@@ -210,17 +223,35 @@ class GraphNode:
210223
211224 Parameters
212225 ----------
213- dst : int
214- Destination pointer (device or pinned host).
215- src : int
216- Source pointer (device or pinned host).
226+ dst : Buffer or int
227+ Destination (device or pinned host). When a :class:`Buffer` is given,
228+ the underlying allocation is retained for the graph's lifetime. A raw
229+ pointer (``int``) is used as-is; the caller must keep the underlying
230+ memory alive, or supply ``dst_owner`` to have the graph retain it.
231+ src : Buffer or int
232+ Source (device or pinned host). Same retention rules as ``dst``;
233+ use ``src_owner`` for a raw pointer.
217234 size : int
218235 Number of bytes to copy.
236+ dst_owner : object, optional
237+ Object retained for the graph's lifetime when ``dst`` is a raw
238+ pointer. A :class:`Buffer` owner retains its underlying allocation.
239+ Must not be passed when ``dst`` is a :class:`Buffer`.
240+ src_owner : object, optional
241+ Object retained for the graph's lifetime when ``src`` is a raw
242+ pointer. A :class:`Buffer` owner retains its underlying allocation.
243+ Must not be passed when ``src`` is a :class:`Buffer`.
219244
220245 Returns
221246 -------
222247 MemcpyNode
223248 A new MemcpyNode representing the copy operation.
249+
250+ Raises
251+ ------
252+ ValueError
253+ If ``dst_owner`` or ``src_owner`` is given together with a
254+ :class:`Buffer` ``dst`` or ``src`` respectively.
224255 """
225256
226257 def embed (self , child : GraphDefinition ) -> ChildGraphNode :
0 commit comments