warp.ScopedAllocator#

class warp.ScopedAllocator(device, allocator)[source]#

Context manager to temporarily use a custom allocator on a device.

On context exit, the previous allocator setting is restored.

Parameters:
  • device (DeviceLike) – The CUDA device on which to set the allocator.

  • allocator (Allocator | None) – The allocator to use, or None to restore the built-in allocator.

Example

with warp.ScopedAllocator(device, my_allocator):
    arr = warp.zeros(1000, dtype=warp.float32, device=device)
__init__(device, allocator)[source]#
Parameters:

Methods

__init__(device, allocator)