Skip to content

Commit 6d4e82d

Browse files
authored
Rename GraphDef -> GraphDefinition and Condition -> GraphCondition (#1984)
Spell out abbreviations for consistency with the rest of cuda.core (#1950) and add the Graph* prefix to Condition for consistency with GraphBuilder / GraphDefinition / GraphNode (#1945). Source file _graph_def.{pyx,pxd} and test files test_graphdef*.py renamed to match. 0.7.0 release notes converted to literal inline-code form for the old GraphDef name so :class: cross-references resolve cleanly in 1.0.0+ doc builds without rewriting historical claims. Made-with: Cursor
1 parent ac24a18 commit 6d4e82d

20 files changed

Lines changed: 222 additions & 209 deletions

cuda_core/cuda/core/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ def _import_versioned_module():
6363
)
6464
from cuda.core._tensor_map import TensorMapDescriptor, TensorMapDescriptorOptions
6565
from cuda.core.graph import (
66-
Condition,
6766
Graph,
6867
GraphAllocOptions,
6968
GraphBuilder,
7069
GraphCompleteOptions,
70+
GraphCondition,
7171
GraphDebugPrintOptions,
72-
GraphDef,
72+
GraphDefinition,
7373
)

cuda_core/cuda/core/graph/__init__.pxd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# SPDX-License-Identifier: Apache-2.0
44

5-
from cuda.core.graph._graph_def cimport Condition, GraphDef
5+
from cuda.core.graph._graph_definition cimport GraphCondition, GraphDefinition
66
from cuda.core.graph._graph_node cimport GraphNode
77
from cuda.core.graph._subclasses cimport (
88
AllocNode,

cuda_core/cuda/core/graph/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
GraphCompleteOptions,
99
GraphDebugPrintOptions,
1010
)
11-
from cuda.core.graph._graph_def import (
12-
Condition,
11+
from cuda.core.graph._graph_definition import (
1312
GraphAllocOptions,
14-
GraphDef,
13+
GraphCondition,
14+
GraphDefinition,
1515
)
1616
from cuda.core.graph._graph_node import GraphNode
1717
from cuda.core.graph._subclasses import (

cuda_core/cuda/core/graph/_graph_builder.pyx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -786,19 +786,19 @@ class Graph:
786786
"""
787787
return self._mnff.graph
788788

789-
def update(self, source: "GraphBuilder | GraphDef") -> None:
789+
def update(self, source: "GraphBuilder | GraphDefinition") -> None:
790790
"""Update the graph using a new graph definition.
791791

792792
The topology of the provided source must be identical to this graph.
793793

794794
Parameters
795795
----------
796-
source : :obj:`~graph.GraphBuilder` or :obj:`~graph.GraphDef`
796+
source : :obj:`~graph.GraphBuilder` or :obj:`~graph.GraphDefinition`
797797
The graph definition to update from. A GraphBuilder must have
798798
finished building.
799799

800800
"""
801-
from cuda.core.graph import GraphDef
801+
from cuda.core.graph import GraphDefinition
802802

803803
cdef cydriver.CUgraph cu_graph
804804
cdef cydriver.CUgraphExec cu_exec = <cydriver.CUgraphExec><intptr_t>int(self._mnff.graph)
@@ -807,11 +807,11 @@ class Graph:
807807
if not source._building_ended:
808808
raise ValueError("Graph has not finished building.")
809809
cu_graph = <cydriver.CUgraph><intptr_t>int(source._mnff.graph)
810-
elif isinstance(source, GraphDef):
810+
elif isinstance(source, GraphDefinition):
811811
cu_graph = <cydriver.CUgraph><intptr_t>int(source.handle)
812812
else:
813813
raise TypeError(
814-
f"expected GraphBuilder or GraphDef, got {type(source).__name__}")
814+
f"expected GraphBuilder or GraphDefinition, got {type(source).__name__}")
815815

816816
cdef cydriver.CUgraphExecUpdateResultInfo result_info
817817
cdef cydriver.CUresult err

cuda_core/cuda/core/graph/_graph_def.pxd renamed to cuda_core/cuda/core/graph/_graph_definition.pxd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ from cuda.bindings cimport cydriver
66
from cuda.core._resource_handles cimport GraphHandle
77

88

9-
cdef class Condition:
9+
cdef class GraphCondition:
1010
cdef:
1111
cydriver.CUgraphConditionalHandle _c_handle
1212
object __weakref__
1313

1414

15-
cdef class GraphDef:
15+
cdef class GraphDefinition:
1616
cdef:
1717
GraphHandle _h_graph
1818
object __weakref__
1919

2020
@staticmethod
21-
cdef GraphDef _from_handle(GraphHandle h_graph)
21+
cdef GraphDefinition _from_handle(GraphHandle h_graph)

cuda_core/cuda/core/graph/_graph_def.pyx renamed to cuda_core/cuda/core/graph/_graph_definition.pyx

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# SPDX-License-Identifier: Apache-2.0
44

5-
"""GraphDef: explicit CUDA graph definition."""
5+
"""GraphDefinition: explicit CUDA graph definition."""
66

77
from __future__ import annotations
88

@@ -28,22 +28,22 @@ from dataclasses import dataclass
2828
from 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

Comments
 (0)