|
17 | 17 | import dpctl.tensor._tensor_impl as ti |
18 | 18 |
|
19 | 19 | from ._elementwise_common import BinaryElementwiseFunc, UnaryElementwiseFunc |
| 20 | +from ._type_utils import _acceptance_fn_divide |
20 | 21 |
|
21 | 22 | # U01: ==== ABS (x) |
22 | 23 | _abs_docstring_ = """ |
|
218 | 219 | """ |
219 | 220 |
|
220 | 221 | divide = BinaryElementwiseFunc( |
221 | | - "divide", ti._divide_result_type, ti._divide, _divide_docstring_ |
| 222 | + "divide", |
| 223 | + ti._divide_result_type, |
| 224 | + ti._divide, |
| 225 | + _divide_docstring_, |
| 226 | + acceptance_fn=_acceptance_fn_divide, |
222 | 227 | ) |
223 | 228 |
|
224 | 229 | # B09: ==== EQUAL (x1, x2) |
|
665 | 670 | ) |
666 | 671 |
|
667 | 672 | # B15: ==== LOGADDEXP (x1, x2) |
668 | | -# FIXME: implement B15 |
| 673 | +_logaddexp_docstring_ = """ |
| 674 | +logaddexp(x1, x2, out=None, order='K') |
| 675 | +
|
| 676 | +Calculates the ratio for each element `x1_i` of the input array `x1` with |
| 677 | +the respective element `x2_i` of the input array `x2`. |
| 678 | +
|
| 679 | +Args: |
| 680 | + x1 (usm_ndarray): |
| 681 | + First input array, expected to have numeric data type. |
| 682 | + x2 (usm_ndarray): |
| 683 | + Second input array, also expected to have numeric data type. |
| 684 | + out ({None, usm_ndarray}, optional): |
| 685 | + Output array to populate. |
| 686 | + Array have the correct shape and the expected data type. |
| 687 | + order ("C","F","A","K", optional): |
| 688 | + Memory layout of the newly output array, if parameter `out` is `None`. |
| 689 | + Default: "K". |
| 690 | +Returns: |
| 691 | + usm_narray: |
| 692 | + An array containing the result of element-wise division. The data type |
| 693 | + of the returned array is determined by the Type Promotion Rules. |
| 694 | +""" |
| 695 | + |
| 696 | +logaddexp = BinaryElementwiseFunc( |
| 697 | + "logaddexp", ti._logaddexp_result_type, ti._logaddexp, _logaddexp_docstring_ |
| 698 | +) |
669 | 699 |
|
670 | 700 | # B16: ==== LOGICAL_AND (x1, x2) |
671 | 701 | _logical_and_docstring_ = """ |
|
1100 | 1130 | order ("C","F","A","K", optional): |
1101 | 1131 | Memory layout of the newly output array, if parameter `out` is `None`. |
1102 | 1132 | Default: "K". |
| 1133 | +Returns: |
| 1134 | + usm_narray: |
| 1135 | + An array containing the result of element-wise division. The data type |
| 1136 | + of the returned array is determined by the Type Promotion Rules. |
| 1137 | +""" |
| 1138 | +trunc = UnaryElementwiseFunc( |
| 1139 | + "trunc", ti._trunc_result_type, ti._trunc, _trunc_docstring |
| 1140 | +) |
| 1141 | + |
| 1142 | + |
| 1143 | +# B24: ==== HYPOT (x1, x2) |
| 1144 | +_hypot_docstring_ = """ |
| 1145 | +hypot(x1, x2, out=None, order='K') |
| 1146 | +
|
| 1147 | +Calculates the ratio for each element `x1_i` of the input array `x1` with |
| 1148 | +the respective element `x2_i` of the input array `x2`. |
| 1149 | +
|
| 1150 | +Args: |
| 1151 | + x1 (usm_ndarray): |
| 1152 | + First input array, expected to have numeric data type. |
| 1153 | + x2 (usm_ndarray): |
| 1154 | + Second input array, also expected to have numeric data type. |
| 1155 | + out ({None, usm_ndarray}, optional): |
| 1156 | + Output array to populate. |
| 1157 | + Array have the correct shape and the expected data type. |
| 1158 | + order ("C","F","A","K", optional): |
| 1159 | + Memory layout of the newly output array, if parameter `out` is `None`. |
| 1160 | + Default: "K". |
1103 | 1161 | Returns: |
1104 | 1162 | usm_narray: |
1105 | 1163 | An array containing the element-wise truncated value of input array. |
1106 | 1164 | The returned array has the same data type as `x`. |
1107 | 1165 | """ |
1108 | 1166 |
|
1109 | | -trunc = UnaryElementwiseFunc( |
1110 | | - "trunc", ti._trunc_result_type, ti._trunc, _trunc_docstring |
| 1167 | +hypot = BinaryElementwiseFunc( |
| 1168 | + "hypot", ti._hypot_result_type, ti._hypot, _hypot_docstring_ |
1111 | 1169 | ) |
0 commit comments