fix float_power/interpolate/baddbmm/fmod/heaviside/index_select doc

This commit is contained in:
fandawei 2023-02-12 09:54:45 +08:00
parent bbca90ef51
commit 38f418d8b7
7 changed files with 56 additions and 54 deletions

View File

@ -11,8 +11,8 @@ mindspore.ops.baddbmm
参数:
- **x** (Tensor) - 输入Tensorshape为 :math:`(C, W, H)`
- **batch1** (Tensor) - 输入Tensorshape为 :math:`(C, W, T)`
- **batch2** (Tensor) - 输入Tensorshape为 :math:`(C, T, H)`
- **batch1** (Tensor) - 公式中的 :math:`batch1` shape为 :math:`(C, W, T)`
- **batch2** (Tensor) - 公式中的 :math:`batch2` shape为 :math:`(C, T, H)`
- **beta** (Union[float, int],可选) - `x` 的系数默认值为1。
- **alpha** (Union[float, int],可选) - :math:`batch1 @ batch2` 的系数默认值为1。

View File

@ -3,10 +3,7 @@ mindspore.ops.float_power
.. py:function:: mindspore.ops.float_power(x, exponent)
计算 `x` 的指数幂。对于实数类型使用mindspore.float64计算。对于复数类型使用输入数据相同类型计算。
.. note::
目前GPU平台不支持数据类型complex。
计算 `x` 的指数幂。对于实数类型,转换 `x``exponent` 到mindspore.float64计算。目前不支持复数运算。
参数:
- **x** (Union[Tensor, Number]) - 第一个输入为Tensor或数值型数据类型。

View File

@ -13,7 +13,7 @@ mindspore.ops.index_select
参数:
- **x** (Tensor) - 输入Tensor。
- **axis** (int) - `index` 的维度。
- **index** (Tensor) - 包含索引的一维Tensor。数据类型为int32或int64。
- **index** (Tensor) - 包含索引的一维Tensor。
返回:
Tensor数据类型与输入 `x` 相同。

View File

@ -15,6 +15,7 @@ mindspore.ops.interpolate
.. code-block::
old_i = new_length != 1 ? new_i * (old_length - 1) / (new_length - 1) : 0 # 'align_corners' 为 True
old_i = new_length > 1 ? (new_x + 0.5) * old_length / new_length - 0.5 : 0 # 'align_corners' 为 False
此选项只对'linear'、'bilinear'、'bicubic'和'trilinear'模式有效。默认值False。
@ -59,12 +60,12 @@ mindspore.ops.interpolate
异常:
- **TypeError** - `x` 不是Tensor。
- **TypeError** - `x` 的数据类型不支持
- **TypeError** - `scales` 不是float类型的tuple
- **ValueError** - `scales` 中的数不全是正数
- **TypeError** - `sizes` 不是int64类型的tuple
- **ValueError** - `sizes` 中的数不全是正数
- **TypeError** - `coordinate_transformation_mode` 不是string
- **ValueError** - `coordinate_transformation_mode` 不在支持的列表中
- **TypeError** - `mode` 不是string类型
- **ValueError** - `mode` 不在支持的列表中。
- **ValueError** - `size``scale_factor` 都不为空
- **ValueError** - `size``scale_factor` 都为空
- **ValueError** - `size` 为元组或列表类型时长度不等于 `x.ndim - 2`
- **ValueError** - `scale_factor` 为元组或列表类型时长度不等于 `x.ndim - 2`
- **ValueError** - `mode` 不在模式支持列表中
- **ValueError** - `x.ndim` 不在模式对应维度的支持列表中
- **ValueError** - `size` 不为空, `recompute_scale_factor` 不为空
- **ValueError** - `scale_factor` 不在对应的支持列表中
- **ValueError** - `align_corners` 不在对应的支持列表中。

View File

@ -4437,18 +4437,18 @@ def _check_check_axis_in_range(axis, ndim):
def index_select(x, axis, index):
"""
Returns a new Tensor which indexes the `x` Tensor along dimension `axis` using the entries in `index` .
The returned Tensor has the same number of dimensions as the original Tensor ( `x` ). The `axis` th dimension
has the same size as the length of `index` ; other dimensions have the same size as in the original Tensor.
Generates a new Tensor that accesses the values of `x` along the specified `axis` dimension
using the indices specified in `index`. The new Tensor has the same number of dimensions as `x`,
with the size of the `axis` dimension being equal to the length of `index`, and the size of all other
dimensions will be unchanged from the original `x` Tensor.
.. note::
The value of index must be in the range of `[0, x.shape[axis])`, the result is undefined out of range.
Args:
x (Tensor): Input Tensor.
axis (int): Dimension in which we index.
index (Tensor): The 1-D Tensor containing the indices to index. The data type can be int32 or int64.
x (Tensor): The input Tensor.
axis (int): The dimension to be indexed.
index (Tensor): A 1-D Tensor with the indices to access in `x` along the specified axis.
Returns:
Tensor, has the same dtype as input Tensor.
@ -4466,13 +4466,17 @@ def index_select(x, axis, index):
>>> import mindspore
>>> from mindspore import Tensor, ops
>>> import numpy as np
>>> x = Tensor(np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]], dtype=np.float32))
>>> index = Tensor([0, 2], mindspore.int32)
>>> x = Tensor(np.arange(16).astype(np.float32).reshape(2, 2, 4))
>>> print(x)
[[[ 0. 1. 2. 3.]
[ 4. 5. 6. 7.]]
[[ 8. 9. 10. 11.]
[12. 13. 14. 15.]]]
>>> index = Tensor([0,], mindspore.int32)
>>> y = ops.index_select(x, 1, index)
>>> print(y)
[[1. 3.]
[4. 6.]
[7. 9.]]
[[[ 0. 1. 2. 3.]]
[[ 8. 9. 10. 11.]]]
"""
if not (isinstance(x, Tensor) and isinstance(index, Tensor)):
raise TypeError(f"For 'index_select', inputs `x` and `index` must be all tensors.")

View File

@ -954,7 +954,7 @@ def divide(x, other, *, rounding_mode=None):
def float_power(x, exponent):
"""
Computes `x` to the power of the exponent.
For the real number type, cast x and expoent to mindspore.float64 to calculate.
For the real number type, cast `x` and `exponent` to mindspore.float64 to calculate.
Currently, complex type calculation is not supported.
Args:
@ -1069,10 +1069,10 @@ def fmod(x, other):
``Ascend`` ``GPU`` ``CPU``
Examples:
>>> x = Tensor(np.array([-3., -2, -1, 1, 2, 3]), mindspore.float32)
>>> output = ops.fmod(x, 1.5)
>>> x = Tensor(np.array([-4., -3.5, 0, 3.5, 4]), mindspore.float32)
>>> output = ops.fmod(x, 2.5)
>>> print(output)
[ 0. -0.5 -1. 1. 0.5 0. ]
[-1.5 -1. 0. 1. 1.5]
"""
if not (isinstance(x, (Tensor, Tensor_)) or isinstance(other, (Tensor, Tensor_))):
raise TypeError("At least one of the types of inputs must be tensor, " + \
@ -4527,11 +4527,11 @@ def heaviside(x, values):
``GPU`` ``CPU``
Examples:
>>> x = Tensor(np.array([-1.5, 0., 2.]))
>>> values = Tensor(np.array([0.5]))
>>> x = Tensor(np.array([-5., 1., 0., 2., 0.]))
>>> values = Tensor(np.array([3.]))
>>> y = ops.heaviside(x, values)
>>> print(y)
[ 0. 0.5 1. ]
[0. 1. 3. 1. 3.]
"""
heaviside_ = Heaviside()
@ -8111,10 +8111,10 @@ def baddbmm(x, batch1, batch2, beta=1, alpha=1):
\text{out}_{i} = \beta \text{input}_{i} + \alpha (\text{batch1}_{i} \mathbin{@} \text{batch2}_{i})
Args:
x (Tensor): The tensor to be added. When batch1 is a (CxWxT) tensor and batch2 is a (CxTxH) tensor,
x must be broadcastable with (CxWxH) tensor.
batch1 (Tensor): The first batch of matrices to be multiplied. Must be 3-D tensors, dtype is same as x.
batch2 (Tensor): The second batch of matrices to be multiplied. Must be 3-D tensors, dtype is same as x.
x (Tensor): The input Tensor. When batch1 is a (CxWxT) Tensor and batch2 is a (CxTxH) Tensor,
x must be broadcastable with (CxWxH) Tensor.
batch1 (Tensor): :math:`batch1` in the above formula. Must be 3-D Tensor, dtype is same as x.
batch2 (Tensor): :math:`batch2` in the above formula. Must be 3-D Tensor, dtype is same as x.
beta (Union[float, int], optional): multiplier for input. The default is 1.
alpha (Union[float, int], optional): multiplier for `batch1 @ batch2`. The default is 1.
Arguments beta and alpha must be integers when inputs of type not FloatTensor, otherwise they should

View File

@ -1954,6 +1954,7 @@ def interpolate(x, size=None, scale_factor=None, mode="nearest", align_corners=N
.. code-block::
old_i = new_length != 1 ? new_i * (old_length - 1) / (new_length - 1) : 0 # 'align_corners' = True
old_i = new_length > 1 ? (new_x + 0.5) * old_length / new_length - 0.5 : 0 # 'align_corners' = False
This is only valid for 'linear', 'bilinear', 'bicubic', or 'trilinear' modes. Default: False.
@ -2000,17 +2001,16 @@ def interpolate(x, size=None, scale_factor=None, mode="nearest", align_corners=N
Tensor, resized, whose dimensions and dtype are the same as `x`.
Raises:
TypeError: If `x` is not Tensor.
TypeError: If `mode` is not one of 'nearest', 'linear', 'bilinear', 'bicubic',
'trilinear', 'area', nor 'nearest-exact'.
TypeError: If `size` is not one of tuple, list, None.
TypeError: If `scale_factor` is neither int nor None.
TypeError: If `align_corners` is not a bool.
TypeError: If dtype of `x` is neither float16 nor float32.
ValueError: If `size` and `scale_factor` are both None or not None.
ValueError: If shape of `x` or `size` and `mode` are not match.
ValueError: If `scale_factor` is an int which is less than 0.
ValueError: If `size` is a list or tuple whose length is not match `mode`.
TypeError: `x` is not a Tensor.
ValueError: Both `size` and `scale_factor` are not empty.
ValueError: Both `size` and `scale_factor` are empty.
ValueError: When `size` is a tuple or list, its length is not equal to `x.ndim - 2`.
ValueError: When `scale_factor` is a tuple or list, its length is not equal to `x.ndim - 2`.
ValueError: `mode` is not in the list of supported modes.
ValueError: `x.ndim` is not in the list of supported dimensions for the corresponding mode.
ValueError: `size` is not empty, `recompute_scale_factor` is not empty.
ValueError: `scale_factor` is not in the corresponding list of supported values.
ValueError: `align_corners` is not in the corresponding list of supported values.
Examples:
>>> import mindspore