warp.tile_min#

warp.tile_min(
a: Tile[Scalar, tuple[int, ...]],
) → Tile[Scalar, tuple[Literal[1]]]#
  • Kernel: true
  • Python: false
  • Differentiable: false

Compute the minimum of all elements of a tile.

This is a cooperative operation: the threads of the block divide the work between them, so every thread must reach the call.

The reduction covers every element of a regardless of its rank. Floating-point comparisons follow C fmin semantics: a NaN element is treated as missing.

Parameters:

a – The tile to reduce. Must have a scalar element type.

Returns:

A shape-(1,) register tile holding the minimum. Read the value with [0].

Example

@wp.kernel
def find_min(x: wp.array2d[float], lo: wp.array[float]):
    t = wp.tile_load(x, shape=(2, 4))
    wp.tile_store(lo, wp.tile_min(t))

x = wp.array([[3.0, 7.0, 4.0, 9.0], [5.0, 1.0, 2.0, 6.0]], dtype=float)
lo = wp.zeros(1, dtype=float)

wp.launch_tiled(find_min, dim=1, inputs=[x], outputs=[lo], block_dim=4)

print(lo.numpy())
[1.]