warp.tile_empty#
- warp.tile_empty( ) Tile[Any, tuple[int, ...]]#
Allocate a tile of uninitialized items.
The tile’s contents are undefined; overwrite every element before any read. This matches the semantics of
numpy.empty.Because it skips initialization,
tile_emptycan avoid unnecessary stores when every element will be overwritten, especially for"shared"tiles. For accumulator patterns (a += ...), usetile_zeros()instead.- 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:
An uninitialized tile with the requested shape and data type.
Example
@wp.kernel def concatenate(a: wp.array[float], b: wp.array[float], out: wp.array[float]): # every element is written below, so skipping initialization is safe t = wp.tile_empty(shape=(8,), dtype=float, storage="shared") wp.tile_assign(t, wp.tile_load(a, shape=(4,)), offset=(0,)) wp.tile_assign(t, wp.tile_load(b, shape=(4,)), offset=(4,)) wp.tile_store(out, t) 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(8, dtype=float) wp.launch_tiled(concatenate, dim=1, inputs=[a, b], outputs=[out], block_dim=4) print(out.numpy())
[ 1. 2. 3. 4. 10. 20. 30. 40.]