未验证 提交 bba7c5b9 编写于 作者: D David Nicolas 提交者: GitHub

update api in creation.py and search.py; test=document_fix (#43150)

* update api in creation and search.py

* Update creation.py

* Update search.py

* Update search.py

* for ci;test=document_fix

* for ci;test=document_fix
Co-authored-by: NLigoml <39876205+Ligoml@users.noreply.github.com>
上级 0993c3b2
......@@ -54,7 +54,7 @@ def _real_to_complex_dtype(dtype):
def linspace(start, stop, num, dtype=None, name=None):
r"""
This OP return fixed number of evenly spaced values within a given interval.
Return fixed number of evenly spaced values within a given interval.
Args:
start(int|float|Tensor): The input :attr:`start` is start variable of range. It is a scalar, \
......@@ -65,8 +65,7 @@ def linspace(start, stop, num, dtype=None, name=None):
or a Tensor of shape [1] with data type int32.
dtype(np.dtype|str, optional): The data type of output tensor, it could be
int32, int64, float32 and float64. Default: if None, the data type is float32.
name(str, optional): Normally there is no need for user to set this property.
For more information, please refer to :ref:`api_guide_Name`.Default: None.
name(str, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.
Returns:
Tensor: the output data type will be float32, float64. The 1-D tensor with fixed number of evenly spaced values, \
......@@ -169,8 +168,7 @@ def logspace(start, stop, num, base=10.0, dtype=None, name=None):
float32 or float64.
dtype(np.dtype|str, optional): The data type of output tensor, it could be \
int32, int64, float32 or float64. Default: if None, the data type is float32. \
name(str, optional): Normally there is no need for user to set this property. \
For more information, please refer to :ref:`api_guide_Name`. Default: None.
name(str, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.
Returns:
Tensor: The output data type will be float32, float64. The 1-D tensor with \
......@@ -429,7 +427,7 @@ def full_like(x, fill_value, dtype=None, name=None):
dtype(np.dtype|str, optional): The data type of output. The data type can be one
of bool, float16, float32, float64, int32, int64. The default value is None, which means the output
data type is the same as input.
name(str, optional): The default value is None. Normally there is no need for user to set this property. For more information, please refer to :ref:`api_guide_Name`
name(str, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.
Returns:
Tensor: Tensor which is created according to ``x``, ``fill_value`` and ``dtype``.
......@@ -481,7 +479,6 @@ def full_like(x, fill_value, dtype=None, name=None):
def ones(shape, dtype=None, name=None):
"""
Create a Tensor of specified :attr:`shape` and :attr:`dtype` and fill it with 1.
Args:
......@@ -532,9 +529,7 @@ def ones_like(x, dtype=None, name=None):
output tensor. Supported data types: bool, float16, float32, float64,
int32, int64. If ``dtype`` is None, the data type is the same as ``x``.
Default is None.
name(str, optional): The default value is None. Normally there is no
need for user to set this property. For more information, please
refer to :ref:`api_guide_Name`.
name(str, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.
Returns:
Tensor: A Tensor filled with the value 1, with the same shape and
......@@ -593,7 +588,7 @@ def zeros(shape, dtype=None, name=None):
def zeros_like(x, dtype=None, name=None):
"""
This OP returns a Tensor filled with the value 0, with the same shape and
Returns a Tensor filled with the value 0, with the same shape and
data type (use ``dtype`` if ``dtype`` is not None) as ``x``.
Args:
......@@ -603,9 +598,7 @@ def zeros_like(x, dtype=None, name=None):
output tensor. Supported data types: bool, float16, float32, float64,
int32, int64. If ``dtype`` is None, the data type is the same as ``x``.
Default is None.
name(str, optional): The default value is None. Normally there is no
need for user to set this property. For more information, please
refer to :ref:`api_guide_Name`.
name (str, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.
Returns:
Tensor: A Tensor filled with the value 0, with the same shape and
......@@ -637,8 +630,7 @@ def eye(num_rows, num_columns=None, dtype=None, name=None):
dtype(np.dtype|str, optional): The data type of the returned Tensor.
It should be int32, int64, float16, float32, float64. Default: if None, the data type
is float32.
name(str, optional): The default value is None. Normally there is no need for
user to set this property. For more information, please refer to :ref:`api_guide_Name`
name(str, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.
Returns:
Tensor: An identity Tensor or LoDTensor of shape [num_rows, num_columns].
......@@ -698,26 +690,26 @@ def eye(num_rows, num_columns=None, dtype=None, name=None):
def full(shape, fill_value, dtype=None, name=None):
"""
This Op return a Tensor with the ``fill_value`` which size is same as ``shape``.
Return a Tensor with the ``fill_value`` which size is same as ``shape``.
Args:
shape(list|tuple|Tensor): Shape of the Tensor to be created.
The data type is ``int32`` or ``int64`` . If ``shape`` is a list or tuple,
the elements of it should be integers or Tensors with shape [1].
If ``shape`` is an Tensor, it should be an 1-D Tensor .
If ``shape`` is an Tensor, it should be an 1-D Tensor.
fill_value(bool|float|int|Tensor): The constant value
used to initialize the Tensor to be created. If ``fill_value`` is an Tensor, it must be an 1-D Tensor.
dtype(np.dtype|str, optional): Data type of the output Tensor
which can be float16, float32, float64, int32, int64, if dytpe is `None`, the data
type of created Tensor is `float32`
name(str, optional): The default value is None. Normally there is no need for user to set this
property. For more information, please refer to :ref:`api_guide_Name`.
type of created Tensor is `float32`.
name (str, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.
Returns:
Tensor: Tensor which is created according to ``shape``, ``fill_value`` and ``dtype``.
Examples:
.. code-block:: python
:name: code-example1
import paddle
......@@ -775,7 +767,7 @@ def arange(start=0, end=None, step=1, dtype=None, name=None):
dtype(str|np.dtype, optional): The data type of the
output tensor. Supported data types: int32, int64, float32, float64.
If ``dytpe`` is None, the data type is float32. Default is None.
name (str, optional): Name for the operation (optional, default is None). For more information, please refer to :ref:`api_guide_Name`.
name (str, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.
Returns:
Tensor: A 1-D Tensor with values from the interval [``start``, ``end``)
......@@ -913,7 +905,7 @@ def tril(x, diagonal=0, name=None):
the main diagonal. The main diagonal are the set of indices
:math:`\{(i, i)\}` for :math:`i \in [0, \min\{d_{1}, d_{2}\} - 1]` where
:math:`d_{1}, d_{2}` are the dimensions of the matrix.
name (str, optional): Name for the operation (optional, default is None). For more information, please refer to :ref:`api_guide_Name`.
name (str, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.
Returns:
Tensor: Results of lower triangular operation by the specified diagonal of input tensor x,
......@@ -977,8 +969,7 @@ def triu(x, diagonal=0, name=None):
the main diagonal. The main diagonal are the set of indices
:math:`\{(i, i)\}` for :math:`i \in [0, \min\{d_{1}, d_{2}\} - 1]` where
:math:`d_{1}, d_{2}` are the dimensions of the matrix.
name (str, optional): The default value is None. Normally there is no need for
user to set this property. For more information, please refer to :ref:`api_guide_Name`.
name (str, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.
Returns:
Tensor: Results of upper triangular operation by the specified diagonal of input tensor x,
......@@ -1108,7 +1099,7 @@ def diagflat(x, offset=0, name=None):
Args:
x (Tensor): The input tensor. It can be any shape. Its data type should be float32, float64, int32, int64.
offset (int, optional): The diagonal offset. A positive value represents superdiagonal, 0 represents the main diagonal, and a negative value represents subdiagonal. Default: 0 (main diagonal).
name (str, optional): Name for the operation (optional, default is None). For more information, please refer to :ref:`api_guide_Name`.
name (str, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.
Returns:
Tensor, a square matrix. The output data type is the same as input data type.
......@@ -1238,8 +1229,8 @@ def diag(x, offset=0, padding_value=0, name=None):
x (Tensor): The input tensor. Its shape is either 1-D or 2-D. Its data type should be float32, float64, int32, int64.
offset (int, optional): The diagonal offset. A positive value represents superdiagonal, 0 represents the main diagonal, and a negative value represents subdiagonal.
padding_value (int|float, optional): Use this value to fill the area outside the specified diagonal band. Only takes effect when the input is a 1-D Tensor. The default value is 0.
name (str, optional): Name for the operation (optional, default is None). For more information, please refer to :ref:`api_guide_Name`.
name (str, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.
Returns:
Tensor, a square matrix or a vector. The output data type is the same as input data type.
......@@ -1333,8 +1324,7 @@ def empty(shape, dtype=None, name=None):
which can be bool, float16, float32, float64, int32, int64, if dytpe is `None`, the data
type of created Tensor use global default dtype (see ``get_default_dtype``
for details).
name(str, optional): The default value is None. Normally there is no need for user to set this
property. For more information, please refer to :ref:`api_guide_Name`.
name(str, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.
Returns:
Tensor: Tensor which is created according to ``shape`` and ``dtype``, and is uninitialized.
......@@ -1420,8 +1410,7 @@ def empty_like(x, dtype=None, name=None):
dtype(np.dtype|str, optional): The data type of output. The data type can be one
of bool, float16, float32, float64, int32, int64. The default value is None, which means the output
data type is the same as input.
name(str, optional): The default value is None. Normally there is no need for user to set this
property. For more information, please refer to :ref:`api_guide_Name`.
name(str, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.
Returns:
Tensor: Tensor which is created according to ``x`` and ``dtype``, and is uninitialized.
......@@ -1605,8 +1594,7 @@ def clone(x, name=None):
Parameters:
x (Tensor): The input Tensor.
name(str, optional): The default value is None. Normally there is no need for user to set this
property. For more information, please refer to :ref:`api_guide_Name`.
name(str, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.
Returns: A Tensor copied from ``input`` .
......@@ -1693,7 +1681,7 @@ def complex(real, imag, name=None):
Args:
real (Tensor): The real component. The data type should be 'float32' or 'float64'.
imag (Tensor): The image component. The data type should be the same as ``real``.
name (str, optional): Name for the operation (optional, default is None). For more information, please refer to :ref:`api_guide_Name`.
name (str, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.
Returns:
Tensor: The output tensor. The data type is 'complex64' or 'complex128', with the same precision as ``real`` and ``imag``.
......
......@@ -34,7 +34,7 @@ __all__ = []
def argsort(x, axis=-1, descending=False, name=None):
"""
This OP sorts the input along the given axis, and returns the corresponding index tensor for the sorted output values. The default sort algorithm is ascending, if you want the sort algorithm to be descending, you must set the :attr:`descending` as True.
Sorts the input along the given axis, and returns the corresponding index tensor for the sorted output values. The default sort algorithm is ascending, if you want the sort algorithm to be descending, you must set the :attr:`descending` as True.
Args:
x(Tensor): An input N-D Tensor with type float32, float64, int16,
......@@ -45,9 +45,7 @@ def argsort(x, axis=-1, descending=False, name=None):
descending(bool, optional) : Descending is a flag, if set to true,
algorithm will sort by descending order, else sort by
ascending order. Default is false.
name(str, optional): The default value is None. Normally there is no
need for user to set this property. For more information, please
refer to :ref:`api_guide_Name`.
name (str, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.
Returns:
Tensor: sorted indices(with the same shape as ``x``
......@@ -138,7 +136,7 @@ def argmax(x, axis=None, keepdim=False, dtype="int64", name=None):
dtype(str|np.dtype, optional): Data type of the output tensor which can
be int32, int64. The default value is ``int64`` , and it will
return the int64 indices.
name (str, optional): Name for the operation (optional, default is None). For more information, please refer to :ref:`api_guide_Name`.
name (str, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.
Returns:
Tensor, return the tensor of int32 if set :attr:`dtype` is int32, otherwise return the tensor of int64.
......@@ -207,7 +205,7 @@ def argmax(x, axis=None, keepdim=False, dtype="int64", name=None):
def argmin(x, axis=None, keepdim=False, dtype="int64", name=None):
"""
Computing the indices of the min elements of the input tensor's
Computes the indices of the min elements of the input tensor's
element along the provided axis.
Args:
......@@ -220,10 +218,8 @@ def argmin(x, axis=None, keepdim=False, dtype="int64", name=None):
dtype(str, optional): Data type of the output tensor which can
be int32, int64. The default value is 'int64', and it will
return the int64 indices.
name(str, optional): The default value is None. Normally there is no
need for user to set this property. For more information, please
refer to :ref:`api_guide_Name`.
name(str, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.
Returns:
Tensor, return the tensor of `int32` if set :attr:`dtype` is `int32`, otherwise return the tensor of `int64`.
......@@ -301,9 +297,7 @@ def index_select(x, index, axis=0, name=None):
x (Tensor): The input Tensor to be operated. The data of ``x`` can be one of float32, float64, int32, int64.
index (Tensor): The 1-D Tensor containing the indices to index. The data type of ``index`` must be int32 or int64.
axis (int, optional): The dimension in which we index. Default: if None, the ``axis`` is 0.
name(str, optional): The default value is None. Normally there is no
need for user to set this property. For more information, please
refer to :ref:`api_guide_Name`.
name(str, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.
Returns:
Tensor: A Tensor with same data type as ``x``.
......@@ -435,25 +429,25 @@ def nonzero(x, as_tuple=False):
def sort(x, axis=-1, descending=False, name=None):
"""
This OP sorts the input along the given axis, and returns the sorted output tensor. The default sort algorithm is ascending, if you want the sort algorithm to be descending, you must set the :attr:`descending` as True.
Sorts the input along the given axis, and returns the sorted output tensor. The default sort algorithm is ascending, if you want the sort algorithm to be descending, you must set the :attr:`descending` as True.
Args:
x(Tensor): An input N-D Tensor with type float32, float64, int16,
int32, int64, uint8.
axis(int, optional): Axis to compute indices along. The effective range
is [-R, R), where R is Rank(x). when axis<0, it works the same way
as axis+R. Default is 0.
as axis+R. Default is -1.
descending(bool, optional) : Descending is a flag, if set to true,
algorithm will sort by descending order, else sort by
ascending order. Default is false.
name(str, optional): The default value is None. Normally there is no
need for user to set this property. For more information, please
refer to :ref:`api_guide_Name`.
name (str, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.
Returns:
Tensor: sorted tensor(with the same shape and data type as ``x``).
Examples:
.. code-block:: python
:name: code-example1
import paddle
......@@ -516,7 +510,7 @@ def sort(x, axis=-1, descending=False, name=None):
def mode(x, axis=-1, keepdim=False, name=None):
"""
This OP is used to find values and indices of the modes at the optional axis.
Used to find values and indices of the modes at the optional axis.
Args:
x(Tensor): Tensor, an input N-D Tensor with type float32, float64, int32, int64.
......@@ -524,7 +518,7 @@ def mode(x, axis=-1, keepdim=False, name=None):
is [-R, R), where R is x.ndim. when axis < 0, it works the same way
as axis + R. Default is -1.
keepdim(bool, optional): Whether to keep the given axis in output. If it is True, the dimensions will be same as input x and with size one in the axis. Otherwise the output dimentions is one fewer than x since the axis is squeezed. Default is False.
name (str, optional): Name for the operation (optional, default is None). For more information, please refer to :ref:`api_guide_Name`.
name (str, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.
Returns:
tuple(Tensor), return the values and indices. The value data type is the same as the input `x`. The indices data type is int64.
......@@ -789,11 +783,10 @@ def masked_select(x, mask, name=None):
Args:
x (Tensor): The input Tensor, the data type can be int32, int64, float32, float64.
mask (Tensor): The Tensor containing the binary mask to index with, it's data type is bool.
name(str, optional): The default value is None. Normally there is no
need for user to set this property. For more information, please
refer to :ref:`api_guide_Name`.
name(str, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.
Returns: A 1-D Tensor which is the same data type as ``x``.
Returns:
A 1-D Tensor which is the same data type as ``x``.
Examples:
......@@ -927,7 +920,7 @@ def searchsorted(sorted_sequence,
right=False,
name=None):
"""
This OP is used to find the index of the corresponding `sorted_sequence` in the innermost dimension based on the given `values`.
Find the index of the corresponding `sorted_sequence` in the innermost dimension based on the given `values`.
Args:
sorted_sequence(Tensor): An input N-D or 1-D tensor with type int32, int64, float32, float64. The value of the tensor monotonically increases in the innermost dimension.
......@@ -935,7 +928,7 @@ def searchsorted(sorted_sequence,
out_int32(bool, optional): Data type of the output tensor which can be int32, int64. The default value is False, and it indicates that the output data type is int64.
right(bool, optional): Find the upper or lower bounds of the sorted_sequence range in the innermost dimension based on the given `values`. If the value of the sorted_sequence is nan or inf, return the size of the innermost dimension.
The default value is False and it shows the lower bounds.
name(str, optional): The default value is None. Normally there is no need for user to set this property. For more information, please refer to :ref:`api_guide_Name`.
name(str, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.
Returns:
Tensor(the same sizes of the `values`), return the tensor of int32 if set :attr:`out_int32` is True, otherwise return the tensor of int64.
......@@ -1001,7 +994,7 @@ def searchsorted(sorted_sequence,
def kthvalue(x, k, axis=None, keepdim=False, name=None):
"""
This OP is used to find values and indices of the k-th smallest at the axis.
Find values and indices of the k-th smallest at the axis.
Args:
x(Tensor): A N-D Tensor with type float32, float64, int32, int64.
......@@ -1010,7 +1003,7 @@ def kthvalue(x, k, axis=None, keepdim=False, name=None):
is [-R, R), where R is x.ndim. when axis < 0, it works the same way
as axis + R. The default is None. And if the axis is None, it will computed as -1 by default.
keepdim(bool, optional): Whether to keep the given axis in output. If it is True, the dimensions will be same as input x and with size one in the axis. Otherwise the output dimentions is one fewer than x since the axis is squeezed. Default is False.
name (str, optional): Name for the operation (optional, default is None). For more information, please refer to :ref:`api_guide_Name`.
name (str, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.
Returns:
tuple(Tensor), return the values and indices. The value data type is the same as the input `x`. The indices data type is int64.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册