warp.utils.array_scan_temp_storage_size#
- warp.utils.array_scan_temp_storage_size(count, dtype, device=None)[source]#
Return the temporary storage size in bytes that
array_scan()needs.Use this to allocate a buffer for the
temp_storageargument ofarray_scan()ahead of time, for example before a graph capture.The size depends on
count, the scalar type ofdtype, and the device. It does not depend on the vector length ofdtype, on whether the scan is inclusive or exclusive, or on the array strides, so one buffer can serve all of these. A buffer sized forcountelements is also large enough for any scan of at mostcountelements with the same scalar type on the same device. CPU scans need no temporary storage, so the size is0on CPU devices.- Parameters:
- Returns:
The number of bytes of temporary storage required.
- Raises:
RuntimeError – If
dtypeis unsupported or if the size query fails.ValueError – If
countis negative or exceeds the 32-bit element limit.
- Return type:
Example
n = 4096 temp = warp.empty( warp.utils.array_scan_temp_storage_size(n, warp.int32, device="cuda:0"), dtype=warp.uint8, device="cuda:0", ) src = warp.ones(n, dtype=warp.int32, device="cuda:0") dst = warp.empty_like(src) with warp.ScopedCapture(device="cuda:0") as capture: warp.utils.array_scan(src, dst, inclusive=False, temp_storage=temp)