cupy.where#

cupy.where(condition, x=None, y=None)[source]#

Return elements, either from x or y, depending on condition.

If only condition is given, return condition.nonzero().

Parameters:
  • condition (cupy.ndarray) – When True, take x, otherwise take y.

  • x (cupy.ndarray) – Values from which to choose on True.

  • y (cupy.ndarray) – Values from which to choose on False.

Returns:

Each element of output contains elements of x when condition is True, otherwise elements of y. If only condition is given, return the tuple condition.nonzero(), the indices where condition is True.

Return type:

cupy.ndarray

Warning

This function may synchronize the device if both x and y are omitted.

See also

numpy.where()