|
1 | 1 | # Data Parallel Control (dpctl) |
2 | 2 | # |
3 | | -# Copyright 2020-2022 Intel Corporation |
| 3 | +# Copyright 2020-2023 Intel Corporation |
4 | 4 | # |
5 | 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | # you may not use this file except in compliance with the License. |
@@ -40,6 +40,37 @@ def _where_result_type(dt1, dt2, dev): |
40 | 40 |
|
41 | 41 |
|
42 | 42 | def where(condition, x1, x2): |
| 43 | + """where(condition, x1, x2) |
| 44 | +
|
| 45 | + Returns :class:`dpctl.tensor.usm_ndarray` with elements chosen |
| 46 | + from `x1` or `x2` depending on `condition`. |
| 47 | +
|
| 48 | + Args: |
| 49 | + condition (usm_ndarray): When True yields from `x1`, |
| 50 | + and otherwise yields from `x2`. |
| 51 | + Must be compatible with `x1` and `x2` according |
| 52 | + to broadcasting rules. |
| 53 | + x1 (usm_ndarray): Array from which values are chosen when |
| 54 | + `condition` is True. |
| 55 | + Must be compatible with `condition` and `x2` according |
| 56 | + to broadcasting rules. |
| 57 | + x2 (usm_ndarray): Array from which values are chosen when |
| 58 | + `condition` is not True. |
| 59 | + Must be compatible with `condition` and `x2` according |
| 60 | + to broadcasting rules. |
| 61 | +
|
| 62 | + Returns: |
| 63 | + usm_ndarray: |
| 64 | + An array with elements from `x1` where `condition` is True, |
| 65 | + and elements from `x2` elsewhere. |
| 66 | +
|
| 67 | + The data type of the returned array is determined by applying |
| 68 | + the Type Promotion Rules to `x1` and `x2`. |
| 69 | +
|
| 70 | + The memory layout of the returned array is |
| 71 | + F-contiguous (column-major) when all inputs are F-contiguous, |
| 72 | + and C-contiguous (row-major) otherwise. |
| 73 | + """ |
43 | 74 | if not isinstance(condition, dpt.usm_ndarray): |
44 | 75 | raise TypeError( |
45 | 76 | "Expecting dpctl.tensor.usm_ndarray type, " f"got {type(condition)}" |
|
0 commit comments