Skip to content

Commit 501ff54

Browse files
Output of searchsorted must always have default indexing data type
This is mandated by array API specification
1 parent f3caaa1 commit 501ff54

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

dpctl/tensor/_searchsorted.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55

66
from ._copy_utils import _empty_like_orderK
77
from ._ctors import empty
8-
from ._data_types import int32, int64
98
from ._tensor_impl import _copy_usm_ndarray_into_usm_ndarray as ti_copy
109
from ._tensor_impl import _take as ti_take
10+
from ._tensor_impl import (
11+
default_device_index_type as ti_default_device_index_type,
12+
)
1113
from ._tensor_sorting_impl import _searchsorted_left, _searchsorted_right
12-
from ._type_utils import iinfo, isdtype, result_type
14+
from ._type_utils import isdtype, result_type
1315
from ._usmarray import usm_ndarray
1416

1517

@@ -141,9 +143,9 @@ def searchsorted(
141143
x2 = x2_buf
142144

143145
dst_usm_type = du.get_coerced_usm_type([x1.usm_type, x2.usm_type])
144-
dst_dt = int32 if x2.size <= iinfo(int32).max else int64
146+
index_dt = ti_default_device_index_type(q)
145147

146-
dst = _empty_like_orderK(x2, dst_dt, usm_type=dst_usm_type)
148+
dst = _empty_like_orderK(x2, index_dt, usm_type=dst_usm_type)
147149

148150
if side == "left":
149151
ht_ev, _ = _searchsorted_left(

0 commit comments

Comments
 (0)