XPUGraph#
- class torch.xpu.XPUGraph(keep_graph=False)[source]#
Wrapper around a XPU graph.
- Parameters:
keep_graph (bool, optional) – If
keep_graph=False, the executable command graph will be instantiated on GPU at the end ofcapture_endand the underlying modifiable command graph will be destroyed. Note that the executable command graph will not be instantiated at the end ofcapture_endin this case. Instead, it will be instantiated via an explicit called toinstantiateor automatically on the first call toreplayifinstantiatewas not already called. Callinginstantiatemanually beforereplayis recommended to prevent increased latency on the first call toreplay.- Return type:
Self
- capture_begin(pool=None)[source]#
Begin capturing XPU work on the current xpu stream.
Typically, you shouldn’t call
capture_beginyourself. Usegraph, which callcapture_begininternally.- Parameters:
pool (optional) – Token (returned by
graph_pool_handle()orother_Graph_instance.pool()) that hints this graph may share memory with the indicated pool.
- capture_end()[source]#
End XPU graph capture on the current stream.
After
capture_end,replaymay be called on this instance.Typically, you shouldn’t call
capture_endyourself. Usegraph, which callcapture_endinternally.
- debug_dump(debug_path)[source]#
- Parameters:
debug_path (required) – Path to dump the graph to.
Calls a debugging function to dump the graph if the debugging is enabled via XPUGraph.enable_debug_mode()
- instantiate()[source]#
Instantiate the XPU graph. Will be called by
capture_endifkeep_graph=False, or byreplayifkeep_graph=Trueandinstantiatehas not already been explicitly called. Does not destroy the xpu modify command graph returned byraw_xpu_graph.
- pool()[source]#
Return an opaque token representing the id of this graph’s memory pool.
This id can optionally be passed to another graph’s
capture_begin, which hints the other graph may share the same memory pool.- Return type:
_POOL_HANDLE
- raw_xpu_graph()[source]#
Returns the underlying xpuGraph_t.
keep_graphmust be True.XPU doesn’t provide APIs to manipulate this object.
- Return type:
- raw_xpu_graph_exec()[source]#
Returns the underlying xpuGraphExec_t.
instantiatemust have been called ifkeep_graphis True, orcapture_endmust have been called ifkeep_graphis False. If you callinstantiate()afterraw_xpu_graph_exec(), the previously returned xpuGraphExec_t will be destroyed. It is your responsibility not to use this object after destruction.XPU doesn’t provide APIs to manipulate this object.
- Return type: