mindspore.ops.searchsorted
- mindspore.ops.searchsorted(sorted_sequence, values, *, out_int32=False, right=False, side=None, sorter=None)[source]
Return the position indices where the elements can be inserted into the input tensor to maintain the increasing order of the input tensor.
- Parameters
- Keyword Arguments
out_int32 (bool, optional) – Whether the output datatype will be mindspore.int32. if
False
, the output datatype will be mindspore.int64. DefaultFalse
.right (bool, optional) – Search Strategy. If
True
, return the last suitable index found; ifFalse
, return the first such index. DefaultFalse
.side (str, optional) – the same as right but preferred.
left
corresponds toFalse
for right andright
corresponds toTrue
for right. An error will be reported if this parameter is set toleft
while right isTrue
. DefaultNone
.sorter (Tensor, optional) – An index sequence sorted in ascending order along the innermost dimension of sorted_sequence , which is used together with the unsorted sorted_sequence . CPU and GPU only support
None
. DefaultNone
.
- Returns
Tensor
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import mindspore >>> sorted_sequence = mindspore.tensor([1, 2, 2, 3, 4, 5, 5]) >>> values = mindspore.tensor([2]) >>> mindspore.ops.searchsorted(sorted_sequence, values) Tensor(shape=[1], dtype=Int64, value= [1])