warp.tile_full#

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

Allocate a tile filled with the specified value.

Every element is initialized with value. Omitting dtype gives a tile whose element type is the type of value. When dtype is provided, a scalar value is converted to it; a composite or Warp struct value must already have that type.

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

  • value – Value to fill the tile with.

  • 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 tile with the requested shape and data type filled with value.

Example

@wp.kernel
def clamp_below(x: wp.array[float], out: wp.array[float]):
    lo = wp.tile_full(shape=(4,), value=2.0, dtype=float)
    t = wp.tile_load(x, shape=(4,))
    wp.tile_store(out, wp.tile_map(wp.max, t, lo))

x = wp.array([1.0, 2.0, 3.0, 4.0], dtype=float)
out = wp.zeros(4, dtype=float)

wp.launch_tiled(clamp_below, dim=1, inputs=[x], outputs=[out], block_dim=2)

print(out.numpy())
[2. 2. 3. 4.]
warp.tile_full(
shape: int32,
value: Any,
dtype: Any = ...,
storage: str = 'register',
) Tile[Any, tuple[int, ...]]
  • Kernel: true
  • Python: false
  • Differentiable: false

Allocate a tile filled with the specified value.

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.