22#
33# SPDX-License-Identifier: Apache-2.0
44
5- """ GraphDef : explicit CUDA graph definition."""
5+ """ GraphDefinition : explicit CUDA graph definition."""
66
77from __future__ import annotations
88
@@ -28,22 +28,22 @@ from dataclasses import dataclass
2828from cuda.core._utils.cuda_utils import driver
2929
3030
31- cdef class Condition :
31+ cdef class GraphCondition :
3232 """ A condition variable for conditional graph nodes.
3333
34- Created by :meth:`GraphDef .create_condition` and passed to
34+ Created by :meth:`GraphDefinition .create_condition` and passed to
3535 conditional-node builder methods (``if_cond``, ``if_else``,
3636 ``while_loop``, ``switch``). The underlying value is set at
3737 runtime by device code via ``cudaGraphSetConditional``.
3838 """
3939
4040 def __repr__ (self ) -> str:
41- return f"<Condition handle = 0x {< unsigned long long > self ._c_handle:x}> "
41+ return f"<GraphCondition handle = 0x {< unsigned long long > self ._c_handle:x}> "
4242
4343 def __eq__(self , other ) -> bool:
44- if not isinstance(other , Condition ):
44+ if not isinstance(other , GraphCondition ):
4545 return NotImplemented
46- return self ._c_handle == (< Condition > other)._c_handle
46+ return self ._c_handle == (< GraphCondition > other)._c_handle
4747
4848 def __hash__ (self ) -> int:
4949 return hash(<unsigned long long>self._c_handle )
@@ -90,10 +90,10 @@ class GraphAllocOptions:
9090 peer_access: list | None = None
9191
9292
93- cdef class GraphDef :
93+ cdef class GraphDefinition :
9494 """ A graph definition.
9595
96- A GraphDef is used to construct a graph explicitly by adding nodes
96+ A GraphDefinition is used to construct a graph explicitly by adding nodes
9797 and specifying dependencies. Once construction is complete, call
9898 instantiate() to obtain an executable Graph.
9999 """
@@ -106,19 +106,19 @@ cdef class GraphDef:
106106 self._h_graph = create_graph_handle(graph)
107107
108108 @staticmethod
109- cdef GraphDef _from_handle(GraphHandle h_graph):
110- """ Create a GraphDef from an existing GraphHandle (internal use)."""
111- cdef GraphDef g = GraphDef .__new__(GraphDef )
109+ cdef GraphDefinition _from_handle(GraphHandle h_graph):
110+ """ Create a GraphDefinition from an existing GraphHandle (internal use)."""
111+ cdef GraphDefinition g = GraphDefinition .__new__(GraphDefinition )
112112 g._h_graph = h_graph
113113 return g
114114
115115 def __repr__(self) -> str:
116- return f"<GraphDef handle=0x{as_intptr(self._h_graph):x}>"
116+ return f"<GraphDefinition handle=0x{as_intptr(self._h_graph):x}>"
117117
118118 def __eq__(self, other) -> bool:
119- if not isinstance(other, GraphDef ):
119+ if not isinstance(other, GraphDefinition ):
120120 return NotImplemented
121- return as_intptr(self._h_graph) == as_intptr((<GraphDef >other)._h_graph)
121+ return as_intptr(self._h_graph) == as_intptr((<GraphDefinition >other)._h_graph)
122122
123123 def __hash__(self) -> int:
124124 return hash(as_intptr(self._h_graph))
@@ -190,7 +190,7 @@ cdef class GraphDef:
190190 """
191191 return self._entry.memcpy(dst, src, size)
192192
193- def embed(self, child: GraphDef ) -> "ChildGraphNode":
193+ def embed(self, child: GraphDefinition ) -> "ChildGraphNode":
194194 """ Add an entry- point child graph node (no dependencies).
195195
196196 See :meth:`GraphNode.embed` for full documentation.
@@ -218,10 +218,10 @@ cdef class GraphDef:
218218 """
219219 return self._entry.callback(fn, user_data=user_data)
220220
221- def create_condition(self, default_value: int | None = None) -> Condition :
221+ def create_condition(self, default_value: int | None = None) -> GraphCondition :
222222 """ Create a condition variable for use with conditional nodes.
223223
224- The returned :class :`Condition ` object is passed to conditional- node
224+ The returned :class :`GraphCondition ` object is passed to conditional- node
225225 builder methods. Its value is controlled at runtime by device code
226226 via ``cudaGraphSetConditional``.
227227
@@ -233,7 +233,7 @@ cdef class GraphDef:
233233
234234 Returns
235235 -------
236- Condition
236+ GraphCondition
237237 A condition variable for controlling conditional execution.
238238 """
239239 cdef cydriver.CUgraphConditionalHandle c_handle
@@ -250,32 +250,32 @@ cdef class GraphDef:
250250 HANDLE_RETURN(cydriver.cuGraphConditionalHandleCreate(
251251 &c_handle, as_cu(self._h_graph), ctx, default_val, flags))
252252
253- cdef Condition cond = Condition .__new__(Condition )
253+ cdef GraphCondition cond = GraphCondition .__new__(GraphCondition )
254254 cond._c_handle = c_handle
255255 return cond
256256
257- def if_cond(self, condition: Condition ) -> "IfNode":
257+ def if_cond(self, condition: GraphCondition ) -> "IfNode":
258258 """ Add an entry- point if - conditional node (no dependencies).
259259
260260 See :meth:`GraphNode.if_cond` for full documentation.
261261 """
262262 return self._entry.if_cond(condition)
263263
264- def if_else(self, condition: Condition ) -> "IfElseNode":
264+ def if_else(self, condition: GraphCondition ) -> "IfElseNode":
265265 """ Add an entry- point if - else conditional node (no dependencies).
266266
267267 See :meth:`GraphNode.if_else` for full documentation.
268268 """
269269 return self._entry.if_else(condition)
270270
271- def while_loop(self, condition: Condition ) -> "WhileNode":
271+ def while_loop(self, condition: GraphCondition ) -> "WhileNode":
272272 """ Add an entry- point while - loop conditional node (no dependencies).
273273
274274 See :meth:`GraphNode.while_loop` for full documentation.
275275 """
276276 return self._entry.while_loop(condition)
277277
278- def switch(self, condition: Condition , unsigned int count) -> "SwitchNode":
278+ def switch(self, condition: GraphCondition , unsigned int count) -> "SwitchNode":
279279 """ Add an entry- point switch conditional node (no dependencies).
280280
281281 See :meth:`GraphNode.switch` for full documentation.
0 commit comments