dpctl.tensor.where¶
- dpctl.tensor.where(condition, x1, x2, /, *, order='K', out=None)[source]¶
Returns
dpctl.tensor.usm_ndarray
with elements chosen fromx1
orx2
depending oncondition
.- Parameters:
condition (usm_ndarray) – When
True
yields fromx1
, and otherwise yields fromx2
. Must be compatible withx1
andx2
according to broadcasting rules.x1 (Union[usm_ndarray, bool, int, float, complex]) – Array from which values are chosen when
condition
isTrue
. Must be compatible withcondition
andx2
according to broadcasting rules.x2 (Union[usm_ndarray, bool, int, float, complex]) – Array from which values are chosen when
condition
is notTrue
. Must be compatible withcondition
andx2
according to broadcasting rules.order (
"K"
,"C"
,"F"
,"A"
, optional) – Memory layout of the new output array, if parameterout
isNone
. Default:"K"
.out (Optional[usm_ndarray]) – the array into which the result is written. The data type of out must match the expected shape and the expected data type of the result. If
None
then a new array is returned. Default:None
.
- Returns:
An array with elements from
x1
wherecondition
isTrue
, and elements fromx2
elsewhere.- Return type:
The data type of the returned array is determined by applying the Type Promotion Rules to
x1
andx2
.