warp.capture_if#
- warp.capture_if(
- condition,
- on_true=None,
- on_false=None,
- stream=None,
- **kwargs,
Create a dynamic branch based on a condition.
The condition value is retrieved from the first element of the
conditionarray.This function is particularly useful during graph capture, but can be used without graph capture as well. CUDA 12.4+ is required for CUDA graph conditional nodes. A
Graphbranch must be a finished capture on the same device asconditionand must not itself containcapture_if()orcapture_while(). CUDA captures withapic=Truedo not yet supportGraphbranches, and CPU captures do not yet support aGraphfromcapture_load().capture_save()rejects a CPU graph that records aGraphbranch.- Parameters:
condition (warp.array[warp.int32]) – Warp array holding the condition value.
on_true (Callable | Graph | None) – A callback function or
Graphto execute if the condition is True.on_false (Callable | Graph | None) – A callback function or
Graphto execute if the condition is False.stream (Stream) – The CUDA stream where the condition was written. If None, use the current stream on the device where
conditionresides.
Any additional keyword arguments are forwarded to the callback functions.