cuda.core.graph.GraphDef#

class cuda.core.graph.GraphDef#

A graph definition.

A GraphDef is used to construct a graph explicitly by adding nodes and specifying dependencies. Once construction is complete, call instantiate() to obtain an executable Graph.

Methods

__init__()#

Create a new empty graph definition.

alloc(
self,
size_t size,
options: GraphAllocOptions | None = None,
) 'AllocNode'#

Add an entry-point memory allocation node (no dependencies).

See GraphNode.alloc() for full documentation.

callback(self, fn, *, user_data=None) 'HostCallbackNode'#

Add an entry-point host callback node (no dependencies).

See GraphNode.callback() for full documentation.

create_condition(
self,
int default_value: int | None = None,
) Condition#

Create a condition variable for use with conditional nodes.

The returned Condition object is passed to conditional-node builder methods. Its value is controlled at runtime by device code via cudaGraphSetConditional.

Parameters:

default_value (int, optional) – The default value to assign to the condition. If None, no default is assigned.

Returns:

A condition variable for controlling conditional execution.

Return type:

Condition

debug_dot_print(self, str path: str, options=None) None#

Write a GraphViz DOT representation of the graph to a file.

Parameters:
  • path (str) – File path for the DOT output.

  • options (GraphDebugPrintOptions, optional) – Customizable options for the debug print.

edges(self) set#

Return all edges in the graph as (from_node, to_node) pairs.

Returns:

Each element is a (from_node, to_node) pair representing a dependency edge in the graph.

Return type:

set of tuple

embed(self, GraphDef child: GraphDef) 'ChildGraphNode'#

Add an entry-point child graph node (no dependencies).

See GraphNode.embed() for full documentation.

empty(self) 'EmptyNode'#

Add an entry-point empty node (no dependencies).

Returns:

A new EmptyNode with no dependencies.

Return type:

EmptyNode

free(self, dptr) 'FreeNode'#

Add an entry-point memory free node (no dependencies).

See GraphNode.free() for full documentation.

if_cond(self, Condition condition: Condition) 'IfNode'#

Add an entry-point if-conditional node (no dependencies).

See GraphNode.if_cond() for full documentation.

if_else(self, Condition condition: Condition) 'IfElseNode'#

Add an entry-point if-else conditional node (no dependencies).

See GraphNode.if_else() for full documentation.

instantiate(self, options=None)#

Instantiate the graph definition into an executable Graph.

Parameters:

options (GraphCompleteOptions, optional) – Customizable dataclass for graph instantiation options.

Returns:

An executable graph that can be launched on a stream.

Return type:

Graph

join(self, *nodes) 'EmptyNode'#

Create an empty node that depends on all given nodes.

Parameters:

*nodes (GraphNode) – Nodes to merge.

Returns:

A new EmptyNode that depends on all input nodes.

Return type:

EmptyNode

launch(self, config, kernel, *args) 'KernelNode'#

Add an entry-point kernel launch node (no dependencies).

See GraphNode.launch() for full documentation.

memcpy(self, dst, src, size_t size) 'MemcpyNode'#

Add an entry-point memcpy node (no dependencies).

See GraphNode.memcpy() for full documentation.

memset(
self,
dst,
value,
size_t width,
size_t height=1,
size_t pitch=0,
) 'MemsetNode'#

Add an entry-point memset node (no dependencies).

See GraphNode.memset() for full documentation.

nodes(self) set#

Return all nodes in the graph.

Returns:

All nodes in the graph.

Return type:

set of GraphNode

record_event(self, event) 'EventRecordNode'#

Add an entry-point event record node (no dependencies).

See GraphNode.record_event() for full documentation.

switch(
self,
Condition condition: Condition,
unsigned int count,
) 'SwitchNode'#

Add an entry-point switch conditional node (no dependencies).

See GraphNode.switch() for full documentation.

wait_event(self, event) 'EventWaitNode'#

Add an entry-point event wait node (no dependencies).

See GraphNode.wait_event() for full documentation.

while_loop(
self,
Condition condition: Condition,
) 'WhileNode'#

Add an entry-point while-loop conditional node (no dependencies).

See GraphNode.while_loop() for full documentation.

Attributes