warp.tile_zeros#

warp.tile_zeros(
shape: tuple[int, ...],
dtype: Any = float,
storage: str = 'register',
) Tile[Any, tuple[int, ...]]#
  • Kernel: true
  • Python: false
  • Differentiable: false

Allocate a tile of zero-initialized items.

Every element is set to the zero value of dtype. Scalar, vector, matrix, and Warp struct element types are all zero-filled component-wise.

Parameters:
  • shape – Shape of the output tile. Must be a compile-time constant.

  • dtype – Data type of output tile’s elements. Must be a compile-time constant.

  • storage – The storage location for the tile: "register" for registers or "shared" for shared memory. Must be a compile-time constant.

Returns:

A zero-initialized tile with the requested shape and data type.

Example

@wp.kernel
def add_tiles(a: wp.array[float], b: wp.array[float], out: wp.array[float]):
    total = wp.tile_zeros(shape=(4,), dtype=float)
    total += wp.tile_load(a, shape=(4,))
    total += wp.tile_load(b, shape=(4,))
    wp.tile_store(out, total)

a = wp.array([1.0, 2.0, 3.0, 4.0], dtype=float)
b = wp.array([10.0, 20.0, 30.0, 40.0], dtype=float)
out = wp.zeros(4, dtype=float)

wp.launch_tiled(add_tiles, dim=1, inputs=[a, b], outputs=[out], block_dim=2)

print(out.numpy())
[11. 22. 33. 44.]
warp.tile_zeros(
shape: int32,
dtype: Any = float,
storage: str = 'register',
) Tile[Any, tuple[int, ...]]
  • Kernel: true
  • Python: false
  • Differentiable: false

Allocate a tile of zero-initialized items.

Overload for 1D tiles: shape is the number of elements, equivalent to passing (shape,). See the overload taking a tuple-valued shape argument for usage details and an example.