warp.ScopedCapture#
- class warp.ScopedCapture(
- device=None,
- stream=None,
- force_module_load=None,
- external=False,
- apic=False,
- capture_mode=CaptureMode.THREAD_LOCAL,
Context manager to capture a sequence of operations into a graph.
Captures kernel launches, memory copies, and memsets for later replay with reduced launch overhead. Works on both CPU and CUDA devices. The captured graph is available as the
graphattribute after exiting the context.- Parameters:
device (DeviceLike) – Device on which to capture operations (CPU or CUDA).
stream – Stream on which to capture operations (CUDA only).
force_module_load – If
True, force all modules to load before capture begins.external – If
True, indicates an external graph capture is already active. Thecapture_modeargument should specify the mode that was used to initiate the external capture.apic (bool) – If
True, enable APIC recording for serialization viacapture_save(). On CPU, recording always occurs regardless of this flag (needed for CPU graph replay). Default isFalse.capture_mode (CaptureMode) – The
CaptureModeto use when opening the capture. Defaults toCaptureMode.THREAD_LOCAL. Seecapture_begin()for details.
- graph#
The captured graph, available after context exit.
- active#
Whether capture is currently in progress.
Example
with warp.ScopedCapture() as capture: warp.launch(my_kernel, dim=n, inputs=[arr]) # Replay the captured graph warp.capture_launch(capture.graph)
See also
- __init__(
- device=None,
- stream=None,
- force_module_load=None,
- external=False,
- apic=False,
- capture_mode=CaptureMode.THREAD_LOCAL,
- Parameters:
apic (bool)
capture_mode (CaptureMode)
Methods
__init__([device, stream, ...])