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
xwhen conditionisTrue, otherwise elements ofy. If onlyconditionis given, return the tuplecondition.nonzero(), the indices whereconditionis True.
- Each element of output contains elements of
- Return type
Warning
This function may synchronize the device if both
xandyare omitted.See also