Script.where

Contents

Script.where

Script.where(condition, x, y, *, out=None)

Select elements from x or y based on a boolean condition.

Returns x where condition is True, y otherwise. Supports broadcasting. Scalar values for x or y are automatically promoted to tensors.

Parameters:
  • condition (RegisterTensor) – Boolean tensor determining element selection.

  • x (RegisterTensor | Expr | int | float) – Values selected where condition is True.

  • y (RegisterTensor | Expr | int | float) – Values selected where condition is False.

  • out (RegisterTensor, optional) – Output tensor. If not provided, a new tensor is allocated.

Returns:

ret – Tensor with the same dtype as x and y, broadcast to a common shape.

Return type:

RegisterTensor

Notes

  • Thread group: Can be executed by any sized thread group.