Add api docs.

This commit is contained in:
liqiliang 2022-06-02 15:21:39 +08:00
parent 90c807acae
commit ba67f2362b
14 changed files with 206 additions and 57 deletions

View File

@ -56,6 +56,7 @@ functional算子是经过初始化后的Primitive可以直接作为函数使
mindspore.ops.fast_gelu
mindspore.ops.hardshrink
mindspore.ops.padding
mindspore.ops.tanh
损失函数
@ -119,6 +120,7 @@ functional算子是经过初始化后的Primitive可以直接作为函数使
mindspore.ops.inplace_add
mindspore.ops.inplace_sub
mindspore.ops.inplace_update
mindspore.ops.inv
mindspore.ops.invert
mindspore.ops.lerp
mindspore.ops.log
@ -302,10 +304,12 @@ Array操作
mindspore.ops.gather_d
mindspore.ops.gather_nd
mindspore.ops.masked_select
mindspore.ops.matrix_band_part
mindspore.ops.matrix_diag
mindspore.ops.meshgrid
mindspore.ops.nonzero
mindspore.ops.one_hot
mindspore.ops.padding
mindspore.ops.range
mindspore.ops.rank
mindspore.ops.reshape

View File

@ -758,6 +758,80 @@ mindspore.Tensor
- **ValueError** - `num_rows``num_cols` 与 当前Tensor的维度和 `k` 的值不匹配。
- **ValueError** - `align` 取值不在合法值集合内。
.. py:method:: inv()
计算当前Tensor的倒数。
.. math::
out_i = \frac{1}{x_{i} }
其中 `x` 表示当前Tensor。
**返回:**
Tensorshape和类型与当前Tensor相同。
**异常:**
- **TypeError** - 当前Tensor的数据类型不为float16、float32或int32。
.. py:method:: invert()
按位翻转当前Tensor。
.. math::
out_i = ~x_{i}
其中 `x` 表示当前Tensor。
**返回:**
Tensorshape和类型与当前Tensor相同。
**异常:**
- **TypeError** - 当前Tensor的数据类型不为int16或uint16。
.. py:method:: matrix_band_part(lower, upper)
将当前Tensor每个中心带外的所有位置设置为零。
**参数:**
- **lower** (int) - 要保留的子对角线数。`lower` 的数据类型必须是int32或int64。如果为负数则保留整个下三角形。
- **upper** (int) - 要保留的子对角线数。`upper` 的数据类型必须是int32或int64。如果为负数则保留整个上三角形。
**返回:**
Tensorshape和类型与当前Tensor相同。
**异常:**
- **TypeError** - 当前Tensor的数据类型不是float16、float32、float64、int32或int64。
- **TypeError** - 输入的 `lower` 的数据类型不是int32或int64。
- **TypeError** - 输入的 `upper` 的数据类型不是int32或int64。
- **ValueError** - 当前Tensor的shape不是大于或等于2维。
.. py:method:: padding(pad_dim_size=8)
通过填充0将当前Tensor的最后一个维度从1扩展到pad_dim_size。
**参数:**
- **pad_dim_size** (int) - 要扩展的当前Tensor的最后一个维度的值该值必须为正数。默认值8。
**返回:**
Tensor其数据类型和维度必须和输入中的当前Tensor保持一致。
**异常:**
- **TypeError** - `pad_dim_size` 的数据类型不是int。
- **ValueError** - `pad_dim_size` 的值小于1。
- **ValueError** - 当前Tensor的最后一个维度不等于1。
.. py:method:: max(axis=None, keepdims=False, initial=None, where=True)
返回Tensor的最大值或轴方向上的最大值。

View File

@ -5,22 +5,4 @@ mindspore.nn.Softsign
Softsign激活函数。
按元素计算Softsign激活函数。
Softsign函数定义为
.. math::
\text{SoftSign}(x) = \frac{x}{1 + |x|}
**输入:**
**x** (Tensor) - shape为 :math:`(N, *)` 的Tensor, 其中 :math:`*` 表示任意个数的维度。它的数据类型必须为float16或float32。
**输出:**
Tensor数据类型和shape与 `x` 相同。
**异常:**
- **TypeError** - `x` 不是Tensor。
- **TypeError** - `x` 的数据类型既不是float16也不是float32。
更多参考详见 :func:`mindspore.ops.softsign`

View File

@ -5,18 +5,4 @@ mindspore.ops.Inv
按元素计算输入Tensor的倒数。
.. math::
out_i = \frac{1}{x_{i} }
**输入:**
**x** (Tensor) - 任意维度的Tensor。数据类型必须是float16、float32或int32。
**输出:**
Tensorshape和数据类型与 `x` 相同。
**异常:**
- **TypeError** - `x` 不是Tensor。
- **TypeError** - `x` 的数据类型不是float16、float32或int32。
更多参考详见 :func:`mindspore.ops.inv`

View File

@ -5,4 +5,4 @@
翻转输入Tensor的所有元素。
详情请查看 :func:`mindspore.ops.invert`
详情请查看 :func:`mindspore.ops.invert`

View File

@ -5,20 +5,4 @@ mindspore.ops.Padding
将输入Tensor的最后一个维度从1扩展到 `pad_dim_size` 其填充值为0。
**参数:**
- **pad_dim_size** (int) - 指定填充的大小,待扩展的 `x` 的最后一个维度的值必须为正数。默认值8。
**输入:**
- **x** (Tensor) - 输入Tensor其shape为 :math:`(x_1, x_2, ..., x_R)``x` 的秩必须至少为2。 `x` 的最后一个维度必须为1。数据类型为Number。
**输出:**
Tensor其shape是 :math:`(z_1, z_2, ..., z_N)`
**异常:**
- **TypeError** - `pad_dim_size` 不是int。
- **ValueError** - `pad_dim_size` 小于1。
- **ValueError** - `x` 的最后一个维度不等于1。
更多参考详见 :func:`mindspore.ops.padding`

View File

@ -0,0 +1,22 @@
mindspore.ops.inv
=================
.. py:function:: mindspore.ops.inv(x)
计算输入x张量的倒数。
.. math::
out_i = \frac{1}{x_{i} }
**参数:**
- **x** (Tensor) - 任意维度的Tensor。其数据类型为float16、float32或int32。
**返回:**
Tensorshape和类型与输入相同。
**异常:**
- **TypeError** - `x` 不是Tensor。
- **TypeError** - `x` 的数据类型不为float16、float32或int32。

View File

@ -0,0 +1,21 @@
mindspore.ops.invert
====================
.. py:function:: mindspore.ops.invert(x)
按位翻转x张量。
.. math::
out_i = ~x_{i}
**参数:**
- **x** (Tensor) - `x` 的shape为 :math:`(x_1, x_2, ..., x_R)`。其数据类型为int16或uint16。
**返回:**
Tensorshape和类型与输入相同。
**异常:**
- **TypeError** - `x` 的数据类型不为int16或uint16。

View File

@ -0,0 +1,24 @@
mindspore.ops.matrix_band_part
==============================
.. py:function:: mindspore.ops.matrix_band_part(x, lower, upper)
将每个最内层矩阵的中心带外的所有位置设置为零。
**参数:**
- **x** (Tensor) - `x` 的shape为 :math:`(*, m, n)` ,其中 :math:`*` 表示任意batch维度。`x` 的数据类型必须为float16、float32、float64、int32或int64。
- **lower** (int) - 要保留的子对角线数。`lower` 的数据类型必须是int32或int64。如果为负数则保留整个下三角形。
- **upper** (int) - 要保留的子对角线数。`upper` 的数据类型必须是int32或int64。如果为负数则保留整个上三角形。
**返回:**
Tensor其数据类型和维度必须和输入中的 `x` 保持一致。
**异常:**
- **TypeError** - 输入的 `x` 的数据类型不是float16、float32、float64、int32或int64。
- **TypeError** - 输入的 `lower` 的数据类型不是int32或int64。
- **TypeError** - 输入的 `upper` 的数据类型不是int32或int64。
- **ValueError** - `x` 的shape不是大于或等于2维。

View File

@ -0,0 +1,22 @@
mindspore.ops.padding
=====================
.. py:function:: mindspore.ops.padding(x, pad_dim_size=8)
通过填充0将输入张量的最后一个维度从1扩展到pad_dim_size。
**参数:**
- **x** (Tensor) - `x` 的shape为 :math:`(x_1, x_2, ..., x_R)`它的秩必须至少为2它的最后一个维度必须为1。其数据类型为数值型。
- **pad_dim_size** (int) - 要扩展的 `x` 的最后一个维度的值该值必须为正数。默认值8。
**返回:**
Tensor其数据类型和维度必须和输入中的 `x` 保持一致。
**异常:**
- **TypeError** - `pad_dim_size` 的数据类型不是int。
- **ValueError** - `pad_dim_size` 的值小于1。
- **ValueError** - `x` 的最后一个维度不等于1。

View File

@ -0,0 +1,26 @@
mindspore.ops.softsign
======================
.. py:function:: mindspore.ops.softsign(x)
Softsign激活函数。
按元素计算Softsign激活函数。
Softsign函数定义为
.. math::
\text{SoftSign}(x) = \frac{x}{1 + |x|}
**参数:**
**x** (Tensor) - shape为 :math:`(N, *)` 的Tensor, 其中 :math:`*` 表示任意个数的维度。它的数据类型必须为float16或float32。
**返回:**
Tensor数据类型和shape与 `x` 相同。
**异常:**
- **TypeError** - `x` 不是Tensor。
- **TypeError** - `x` 的数据类型既不是float16也不是float32。

View File

@ -56,6 +56,7 @@ Activation Functions
mindspore.ops.fast_gelu
mindspore.ops.hardshrink
mindspore.ops.softsign
mindspore.ops.tanh
Loss Functions
@ -119,6 +120,7 @@ Element-by-Element Operations
mindspore.ops.inplace_add
mindspore.ops.inplace_sub
mindspore.ops.inplace_update
mindspore.ops.inv
mindspore.ops.invert
mindspore.ops.lerp
mindspore.ops.log
@ -301,10 +303,12 @@ Array Operation
mindspore.ops.gather_d
mindspore.ops.gather_nd
mindspore.ops.masked_select
mindspore.ops.matrix_band_part
mindspore.ops.matrix_diag
mindspore.ops.meshgrid
mindspore.ops.nonzero
mindspore.ops.one_hot
mindspore.ops.padding
mindspore.ops.range
mindspore.ops.rank
mindspore.ops.reshape

View File

@ -1247,7 +1247,7 @@ class Tensor(Tensor_):
out_i = \frac{1}{x_{i} }
Returns:
Tensor, has the same type and shape as input shape value.
Tensor, has the same type and shape as self tensor.
Raises:
TypeError: If `x` is not a Tensor.
@ -1274,7 +1274,7 @@ class Tensor(Tensor_):
out_i = ~x_{i}
Returns:
Tensor, has the same shape as `x`.
Tensor, has the same shape as as self tensor.
Raises:
TypeError: If dtype of `x` is neither int16 nor uint16.
@ -1303,7 +1303,7 @@ class Tensor(Tensor_):
If negative, keep entire upper triangle.
Returns:
Tensor, has the same type and shape as input shape value.
Tensor, has the same type and shape as self tensor.
Raises:
TypeError: If dtype of `x` is not one of float16, float32, float64, int32 or int64.
@ -1340,7 +1340,7 @@ class Tensor(Tensor_):
Default: 8.
Returns:
Tensor, has the same type and shape as input shape value.
Tensor, has the same type and shape as self tensor.
Raises:
TypeError: If `pad_dim_size` is not an int.

View File

@ -134,7 +134,7 @@ def matrix_band_part(x, lower, upper):
If negative, keep entire upper triangle.
Returns:
Tensor, has the same type and shape as input shape value.
Tensor, has the same type and shape as `x`.
Raises:
TypeError: If dtype of `x` is not one of float16, float32, float64, int32 or int64.