44
55from __future__ import annotations
66
7- import os
8- import warnings
9- import weakref
107from dataclasses import dataclass
11- from typing import TYPE_CHECKING , Optional , Tuple , Union
8+ from typing import TYPE_CHECKING , Optional , Tuple
129
1310if TYPE_CHECKING :
1411 from cuda .core .experimental ._stream import Stream
1714
1815@dataclass
1916class DebugPrintOptions :
20- """
21- """
17+ """ """
2218
2319 VERBOSE : bool = False
2420 RUNTIME_TYPES : bool = False
@@ -60,7 +56,7 @@ def _init(stream, is_root=True):
6056 # If from Stream, then we can't
6157 self ._stream = stream
6258 self ._capturing = False
63- self ._is_root = is_root # TODO: Is this info needed?
59+ self ._is_root = is_root # TODO: Is this info needed?
6460 return self
6561
6662 def _check_capture_stream_provided (self , * args , ** kwargs ):
@@ -101,8 +97,10 @@ def is_capture_active(self) -> bool:
10197 elif capture_status == driver .CUstreamCaptureStatus .CU_STREAM_CAPTURE_STATUS_ACTIVE :
10298 return True
10399 elif capture_status == driver .CUstreamCaptureStatus .CU_STREAM_CAPTURE_STATUS_INVALIDATED :
104- raise RuntimeError ("Stream is part of a capture sequence that has been invalidated, but "
105- "not terminated. The capture sequence must be terminated with self.`()." )
100+ raise RuntimeError (
101+ "Stream is part of a capture sequence that has been invalidated, but "
102+ "not terminated. The capture sequence must be terminated with self.`()."
103+ )
106104 else :
107105 raise NotImplementedError (f"Unsupported capture stuse type received: { capture_status } " )
108106
@@ -124,30 +122,30 @@ def debug_dot_print(self, path, options: Optional[DebugPrintOptions] = None):
124122
125123 handle_return (driver .cuGraphDebugDotPrint (self ._graph , path , options_value ))
126124
127- def split (self , count ) -> Tuple [Graph , ...]:
125+ def fork (self , count ) -> Tuple [Graph , ...]:
128126 if count <= 1 :
129- raise ValueError (f"Invalid split count: expecting >= 2, got { count } " )
127+ raise ValueError (f"Invalid fork count: expecting >= 2, got { count } " )
130128
131129 # 1. Record an event on our stream
132130 event = self ._stream .record ()
133131
134132 # TODO: Steps 2,3,4 can be combined under a single loop
135133
136- # 2. Create a streams for each of the new splits
137- # TODO: Optimization where one of the split stream is allowed to use
134+ # 2. Create a streams for each of the new forks
135+ # TODO: Optimization where one of the fork stream is allowed to use
138136 # TODO: Should use the same stream options as initial stream??
139- split_stream = [self ._stream .device .create_stream () for i in range (count )]
137+ fork_stream = [self ._stream .device .create_stream () for i in range (count )]
140138
141139 # 3. Have each new stream wait on our singular event
142- for stream in split_stream :
140+ for stream in fork_stream :
143141 stream .wait (event )
144142
145143 # 4. Discard the event
146144 # TODO: Is this actually allowed when using with a graph? Surely, since it just needs to create an edge for us... right?
147145 event .close ()
148146
149- # 5. Create new graph builders for each new stream split
150- return [GraphBuilder ._init (stream = stream , is_root = False ) for stream in split_stream ]
147+ # 5. Create new graph builders for each new stream fork
148+ return [GraphBuilder ._init (stream = stream , is_root = False ) for stream in fork_stream ]
151149
152150 def join (self , * graph_builders ):
153151 if len (graph_builders ) < 1 :
@@ -158,6 +156,18 @@ def join(self, *graph_builders):
158156 # TODO: Can we close each of those new streams? Do we need weakref?
159157 graph .close ()
160158
159+ def create_conditional_handle (self , default_value = None ):
160+ pass
161+
162+ def if_cond (self , handle ):
163+ pass
164+
165+ def if_else (self , handle ):
166+ pass
167+
168+ def switch (self , handle , count ):
169+ pass
170+
161171 def close (self ):
162172 if self ._capturing :
163173 raise RuntimeError ("Trying to close a graph builder who is still capturing" )
@@ -166,8 +176,7 @@ def close(self):
166176
167177
168178class Graph :
169- """
170- """
179+ """ """
171180
172181 def __init__ (self ):
173182 raise RuntimeError ("directly constructing a Graph instance is not supported" )
0 commit comments