mindspore.ops.SearchSorted
- class mindspore.ops.SearchSorted(dtype=mstype.int64, right=False)[source]
Return the position indices where the elements can be inserted into the input tensor to maintain the increasing order of the input tensor.
Warning
This is an experimental API that is subject to change or deletion.
Refer to
mindspore.ops.searchsorted()
for more details.- Parameters
dtype (mindspore.dtype, optional) – The specified type of output tensor. Optional values are:
mstype.int32
andmstype.int64
. Defaultmstype.int64
.right (bool, optional) – Search Strategy. If
True
, return the last suitable index found; ifFalse
, return the first such index. DefaultFalse
.
- Inputs:
sorted_sequence (Tensor) - The input tensor. If sorter not provided, it must contain a increasing sequence on the innermost dimension.
values (Tensor) - The value that need to be inserted.
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
.
- Outputs:
Tensor
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import mindspore >>> sorted_sequence = mindspore.tensor([1, 2, 2, 3, 4, 5, 5], mindspore.float32) >>> values = mindspore.tensor([2], mindspore.float32) >>> mindspore.ops.SearchSorted()(sorted_sequence, values) Tensor(shape=[1], dtype=Int64, value= [1])