Skip to content

Commit 72821c7

Browse files
committed
Split _graphdef.pyx into _graph_def/ subpackage for maintainability
The monolithic _graphdef.pyx (2000+ lines) is split into three focused modules under _graph_def/: _graph_def.pyx (Condition, GraphAllocOptions, GraphDef), _graph_node.pyx (GraphNode base class and builder methods), and _subclasses.pyx (all concrete node subclasses). Long method bodies in GraphNode are factored into cdef inline GN_* helpers following existing codebase conventions. Handle property annotations updated to use driver.* types consistently. Made-with: Cursor
1 parent 51cfcb0 commit 72821c7

File tree

14 files changed

+2236
-2105
lines changed

14 files changed

+2236
-2105
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
from cuda.core._graph._graph_def._graph_def cimport Condition, GraphDef
6+
from cuda.core._graph._graph_def._graph_node cimport GraphNode
7+
from cuda.core._graph._graph_def._subclasses cimport (
8+
AllocNode,
9+
ChildGraphNode,
10+
ConditionalNode,
11+
EmptyNode,
12+
EventRecordNode,
13+
EventWaitNode,
14+
FreeNode,
15+
HostCallbackNode,
16+
IfElseNode,
17+
IfNode,
18+
KernelNode,
19+
MemcpyNode,
20+
MemsetNode,
21+
SwitchNode,
22+
WhileNode,
23+
)
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
"""Explicit CUDA graph construction — GraphDef, GraphNode, and node subclasses."""
6+
7+
from cuda.core._graph._graph_def._graph_def import (
8+
Condition,
9+
GraphAllocOptions,
10+
GraphDef,
11+
)
12+
from cuda.core._graph._graph_def._graph_node import GraphNode
13+
from cuda.core._graph._graph_def._subclasses import (
14+
AllocNode,
15+
ChildGraphNode,
16+
ConditionalNode,
17+
EmptyNode,
18+
EventRecordNode,
19+
EventWaitNode,
20+
FreeNode,
21+
HostCallbackNode,
22+
IfElseNode,
23+
IfNode,
24+
KernelNode,
25+
MemcpyNode,
26+
MemsetNode,
27+
SwitchNode,
28+
WhileNode,
29+
)
30+
31+
__all__ = [
32+
"AllocNode",
33+
"ChildGraphNode",
34+
"Condition",
35+
"ConditionalNode",
36+
"EmptyNode",
37+
"EventRecordNode",
38+
"EventWaitNode",
39+
"FreeNode",
40+
"GraphAllocOptions",
41+
"GraphDef",
42+
"GraphNode",
43+
"HostCallbackNode",
44+
"IfElseNode",
45+
"IfNode",
46+
"KernelNode",
47+
"MemcpyNode",
48+
"MemsetNode",
49+
"SwitchNode",
50+
"WhileNode",
51+
]
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
from cuda.bindings cimport cydriver
6+
from cuda.core._resource_handles cimport GraphHandle
7+
8+
9+
cdef class Condition:
10+
cdef:
11+
cydriver.CUgraphConditionalHandle _c_handle
12+
object __weakref__
13+
14+
15+
cdef class GraphDef:
16+
cdef:
17+
GraphHandle _h_graph
18+
object __weakref__
19+
20+
@staticmethod
21+
cdef GraphDef _from_handle(GraphHandle h_graph)

0 commit comments

Comments
 (0)