warp.tile_ones#

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

Allocate a tile of one-initialized items.

Every element is initialized with dtype(1). For vector and matrix element types this sets every component to one - it does not produce an identity matrix. For quaternion element types dtype(1) sets only the first component, giving (1, 0, 0, 0). Warp struct element types are rejected; use tile_full() with a value of the struct type 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:

A tile with the requested shape whose elements are all dtype(1).

Example

@wp.kernel
def multiply_tiles(a: wp.array[float], b: wp.array[float], out: wp.array[float]):
    total = wp.tile_ones(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(multiply_tiles, dim=1, inputs=[a, b], outputs=[out], block_dim=2)

print(out.numpy())
[ 10.  40.  90. 160.]
warp.tile_ones(
shape: int32,
dtype: Any = float,
storage: str = 'register',
) Tile[Any, tuple[int, ...]]
  • Kernel: true
  • Python: false
  • Differentiable: false

Allocate a tile of one-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.