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
isTrue
, otherwise elements ofy
. If onlycondition
is given, return the tuplecondition.nonzero()
, the indices wherecondition
is True.
- Each element of output contains elements of
- Return type
Warning
This function may synchronize the device if both
x
andy
are omitted.See also