mindspore.ops.searchsorted
- mindspore.ops.searchsorted(sorted_sequence, values, *, out_int32=False, right=False)[source]
Return the position indices such that after inserting the values into the sorted_sequence, the order of innermost dimension of the sorted_sequence remains unchanged.
- Parameters
- Keyword Arguments
- Returns
Tensor containing the indices from the innermost dimension of sorted_sequence such that, if insert the corresponding value in the values tensor, the order of sorted_sequence would be preserved, whose datatype is int32 if out_int32 is True, otherwise int64, and shape is the same as the shape of values.
- Raises
ValueError – If the dimension of sorted_sequence isn’t 1 and all dimensions except the last dimension of sorted_sequence and values are different.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> sorted_sequence = Tensor(np.array([[0, 1, 3, 5, 7], [2, 4, 6, 8, 10]]), mindspore.float32) >>> values = Tensor(np.array([[3, 6, 9], [3, 6, 9]]), mindspore.float32) >>> output = ops.searchsorted(sorted_sequence, values) >>> print(output) [[2 4 5] [1 2 4]]