!48366 Fix SearchSorted ERROR
Merge pull request !48366 from huangxinjing/code_docs_fix_search_sorted
This commit is contained in:
commit
447c73b416
|
@ -344,9 +344,10 @@ Reduction函数
|
|||
mindspore.ops.lt
|
||||
mindspore.ops.maximum
|
||||
mindspore.ops.minimum
|
||||
mindspore.ops.msort
|
||||
mindspore.ops.ne
|
||||
mindspore.ops.not_equal
|
||||
mindspore.ops.msort
|
||||
mindspore.ops.searchsorted
|
||||
mindspore.ops.topk
|
||||
|
||||
线性代数函数
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
mindspore.ops.searchsorted
|
||||
==========================
|
||||
|
||||
.. py:function:: mindspore.ops.searchsorted(sorted_sequence, values, *, out_int32=False, right=False)
|
||||
|
||||
返回位置索引,根据这个索引将`values` 插入 `sorted_sequence`后,`sorted_sequence` 的最内维度的顺序保持不变。
|
||||
|
||||
参数:
|
||||
- **sorted_sequence** (Tensor) - Tensor的形状为:math:`(x_1,x_2,…,x_R-1,x_R)` 或 `x_1`。在最里面的维度上必须包含单调递增的序列。
|
||||
- **values** (Tensor) - 要插入元素的值。Tensor的形状为:math:`(x_1,x_2,…,x_R-1,x_S)`。
|
||||
|
||||
关键字参数:
|
||||
- **out_int32** (bool, 可选) - 输出数据类型。如果为True,则输出数据类型将为int32;如果为False,则输出数据类型将为int64。默认值:False。
|
||||
- **right** (bool, 可选) - 搜索策略。如果为True,则返回找到的最后一个合适的索引;如果为False,则返回第一个合适的索引。默认值:False。
|
||||
|
||||
返回:
|
||||
表示`sorted_sequence`最内维度的索引的Tensor,如果插入`values` tensor中相应的值,则`sorted_sequence` tensor的顺序将被保留,如果out_int32为True,
|
||||
则返回的数据类型为int32,否则为int64,并且形状与values的形状相同。
|
||||
|
||||
异常:
|
||||
- **ValueError** - 如果 `sorted_sequence` 的维度不是1,并且除 `sorted_sequence` 和 `values` 的最后一个维度之外的维度不同。
|
|
@ -344,9 +344,10 @@ Comparison Functions
|
|||
mindspore.ops.lt
|
||||
mindspore.ops.maximum
|
||||
mindspore.ops.minimum
|
||||
mindspore.ops.msort
|
||||
mindspore.ops.ne
|
||||
mindspore.ops.not_equal
|
||||
mindspore.ops.msort
|
||||
mindspore.ops.searchsorted
|
||||
mindspore.ops.topk
|
||||
|
||||
Linear Algebraic Functions
|
||||
|
|
|
@ -150,7 +150,8 @@ from .array_func import (
|
|||
column_stack,
|
||||
hstack,
|
||||
movedim,
|
||||
moveaxis
|
||||
moveaxis,
|
||||
searchsorted
|
||||
)
|
||||
from .parameter_func import (
|
||||
assign,
|
||||
|
|
|
@ -1219,23 +1219,25 @@ def unique_consecutive(x, return_idx=False, return_counts=False, axis=None):
|
|||
|
||||
def searchsorted(sorted_sequence, values, *, out_int32=False, right=False):
|
||||
"""
|
||||
Find the indices from the innermost dimension of `sorted_sequence` such that the order of the innermost dimension
|
||||
within `sorted_sequence` would be preserved when the corresponding values in `values` were inserted before the
|
||||
indices.
|
||||
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.
|
||||
|
||||
Args:
|
||||
sorted_sequence (Tensor): The shape of tensor is :math:`(x_1, x_2, ..., x_R-1, x_R)` or `(x_1)`.
|
||||
It must contain a monotonically increasing sequence on the innermost dimension.
|
||||
values (Tensor): The shape of tensor is :math:`(x_1, x_2, ..., x_R-1, x_S)`.
|
||||
values (Tensor): The value that should be inserted.
|
||||
The shape of tensor is :math:`(x_1, x_2, ..., x_R-1, x_S)`.
|
||||
|
||||
Keyword Args:
|
||||
out_int32 (bool, optional): Output datatype. If True, the output datatype will be int32;
|
||||
if False, the output datatype will be int64. Default: False.
|
||||
right (bool, optional): Search Strategy. If True, return the last suitable index found;
|
||||
if False, return the first such index. Default: False.
|
||||
|
||||
Returns:
|
||||
Tensor containing the indices from the innermost dimension of the input sequence such that,
|
||||
if insert the corresponding value in the values tensor, the order of the tensor 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.
|
||||
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
|
||||
|
@ -1247,7 +1249,7 @@ def searchsorted(sorted_sequence, values, *, out_int32=False, right=False):
|
|||
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)
|
||||
>>> output = ops.searchsorted(sorted_sequence, values)
|
||||
>>> print(output)
|
||||
[[2 4 5]
|
||||
[1 2 4]]
|
||||
|
@ -6715,6 +6717,7 @@ __all__ = [
|
|||
'mvlgamma',
|
||||
'swapaxes',
|
||||
'swapdims',
|
||||
'searchsorted',
|
||||
'argsort',
|
||||
'sequence_mask',
|
||||
'repeat_elements',
|
||||
|
|
Loading…
Reference in New Issue