CodeDocs 中文API资料

This commit is contained in:
hw_hz 2022-11-22 10:37:33 +08:00
parent d8bef934c3
commit 4df50a5df0
10 changed files with 115 additions and 127 deletions

View File

@ -521,9 +521,12 @@ Array操作
mindspore.ops.MaskedSelect
mindspore.ops.MatrixBandPart
mindspore.ops.MatrixDeterminant
mindspore.ops.MatrixDiagPartV3
mindspore.ops.MatrixDiagV3
mindspore.ops.MatrixExp
mindspore.ops.MatrixLogarithm
mindspore.ops.MatrixPower
mindspore.ops.MatrixSetDiagV3
mindspore.ops.MatrixSolve
mindspore.ops.MatrixTriangularSolve
mindspore.ops.Meshgrid

View File

@ -3,6 +3,6 @@ mindspore.ops.GridSampler3D
.. py:class:: mindspore.ops.GridSampler3D
给定一个输入和一个网格,使用网格中的输入值和像素位置计算输出。
给定一个输入和一个网格,使用网格中的输入值和像素位置计算输出。只支持体积(5-D)的输入。
更多参考详见 :func:`mindspore.ops.grid_sample`

View File

@ -0,0 +1,8 @@
mindspore.ops.MatrixDiagPartV3
==============================
.. py:class:: mindspore.ops.MatrixDiagPartV3
返回Tensor的对角线部分。
更多参考详见 :func:`mindspore.ops.matrix_diag_part`

View File

@ -0,0 +1,8 @@
mindspore.ops.MatrixDiagV3
==========================
.. py:class:: mindspore.ops.MatrixDiagV3
返回一个batch的对角Tensor其具有给定的对角线值。
更多参考详见 :func:`mindspore.ops.matrix_diag`

View File

@ -0,0 +1,54 @@
mindspore.ops.MatrixSetDiagV3
=============================
.. py:class:: mindspore.ops.MatrixSetDiagV3(align="RIGHT_LEFT")
返回具有新的对角线值的批处理矩阵Tensor。
给定输入 `x` 和对角线 `diagonal` ,此操作返回与 `x` 具有相同shape和值的Tensor但返回的Tensor除开最内层矩阵的对角线
这些值将被对角线中的值覆盖。如果某些对角线比 `max_diag_len` 短,则需要被填充,其中 `max_diag_len` 指对角线的最长长度。
`diagonal` 的维度 :math:`shape[-2]` 必须等于对角线个数 `num_diags` :math:`num_diags = k[1] - k[0] + 1`
`diagonal` 的维度 :math:`shape[-1]` 必须等于最长对角线值 `max_diag_len`
:math:`max_diag_len = min(x.shape[-2] + min(k[1], 0), x.shape[-1] + min(-k[0], 0))`
`x` 具有 `r + 1`:math:`[I, J, ..., L, M, N]`
`k` 是整数或 :math:`k[0] == k[1]` 时,对角线 `diagonal` 的shape为 :math:`[I, J, ..., L, max\_diag\_len]`
否则其shape为 :math:`[I, J, ... L, num\_diags, max\_diag\_len]`
参数:
- **align** (str可选) - 字符串,指定超对角线和次对角线的对齐方式。
可选值:"RIGHT_LEFT"、"LEFT_RIGHT"、"LEFT_LEFT"、"RIGHT_RIGHT"。
默认值:"RIGHT_LEFT"。
- "RIGHT_LEFT"表示将超对角线与右侧对齐(左侧填充行),将次对角线与左侧对齐(右侧填充行)。
- "LEFT_RIGHT"表示将超对角线与左侧对齐(右侧填充行),将次对角线与右侧对齐(左侧填充行)。
- "LEFT_LEFT"表示将超对角线与左侧对齐(右侧填充行),将次对角线与左侧对齐(右侧填充行)。
- "RIGHT_RIGHT"表示将超对角线与右侧对齐(左侧填充行),将次对角线与右侧对齐(左侧填充行)。
输入:
- **x** (Tensor) - Tensor其维度为 `r+1` 需要满足 `r >=1`
- **diagonal** (Tensor) - 输入对角线Tensor具有与 `x` 相同的数据类型。
`k` 是整数或 :math:`k[0] == k[1]` 时,其为维度 `r` ,否则,其维度为 `r + 1`
- **k** (Tensor) - int32类型的Tensor。对角线偏移量。正值表示超对角线0表示主对角线负值表示次对角线。
`k` 可以是单个整数(对于单个对角线)或一对整数,分别指定矩阵带的上界和下界,且 `k[0]` 不得大于 `k[1]`
其值必须在 :math:`(-x.shape[-2], x.shape[-1])` 中。采用图模式时,输入 `k` 必须是常量Tensor。
输出:
Tensor`x` 的类型相同。
`x``r+1`:math:`[I J ... M N]`
输出Tensor的维度为 `r+1`:math:`[I, J, ..., L, M, N]` ,与输入 `x` 相同。
异常:
- **TypeError** - 若任一输入不是Tensor。
- **TypeError** - `x``diagonal` 数据类型不同。
- **TypeError** - `k` 的数据类型不为int32。
- **ValueError** - `align` 取值不在合法值集合内。
- **ValueError** - `k` 的维度不为0或1。
- **ValueError** - `x` 的维度不大于等于2。
- **ValueError** - `k` 的大小不为1或2。
- **ValueError** - 当 `k` 的大小为2时 `k[1]` 小于 `k[0]`
- **ValueError** - 对角线 `diagonal` 的维度与输入 `x` 的维度不匹配。
- **ValueError** - 对角线 `diagonal` 的shape与输入 `x` 不匹配。
- **ValueError** - 对角线 `diagonal` 的维度 :math:`shape[-2]` 不等于与对角线个数 `num_diags`
:math:`num_diags = k[1]-k[0]+1`
- **ValueError** - `k` 的取值不在 :math:`(-x.shape[-2], x.shape[-1])` 范围内。
- **ValueError** - 对角线 `diagonal` 的维度 :math:`shape[-1]` 不等于最长对角线长度 `max_diag_len`
:math:`max_diag_len = min(x.shape[-2] + min(k[1], 0), x.shape[-1] + min(-k[0], 0))`

View File

@ -520,9 +520,12 @@ Array Operation
mindspore.ops.MaskedSelect
mindspore.ops.MatrixBandPart
mindspore.ops.MatrixDeterminant
mindspore.ops.MatrixDiagPartV3
mindspore.ops.MatrixDiagV3
mindspore.ops.MatrixExp
mindspore.ops.MatrixLogarithm
mindspore.ops.MatrixPower
mindspore.ops.MatrixSetDiagV3
mindspore.ops.MatrixSolve
mindspore.ops.MatrixTriangularSolve
mindspore.ops.Meshgrid

View File

@ -1350,17 +1350,29 @@ class MatrixSetDiagV3(Primitive):
Returns a batched matrix tensor with new batched diagonal values.
Given x and diagonal, this operation returns a tensor with the same shape and values as x, except for the specified
diagonals of the innermost matrices. These will be overwritten by the values in diagonal. Some diagonals are shorter
than max_diag_len and need to be padded.
The diagonal.shape[-2] must be equal to num_diags calculated by k[1] - k[0] + 1. The diagonal.shape[-1] must be
equal to the longest diagonal value max_diag_len calculated by min(x.shape[-2] + min(k[1], 0), x.shape[-1] +
min(-k[0], 0)). Let x have r + 1 dimensions [I, J, ..., L, M, N]. The diagonal tensor has rank r with shape [I, J,
..., L, max_diag_len] when k is an integer or k[0] == k[1]. Otherwise, it has rank r + 1 with shape [I, J, ..., L,
num_diags, max_diag_len].
than `max_diag_len` and need to be padded, where `max_diag_len` is the longest diagonal value.
The diagonal.shape[-2] must be equal to num_diags calculated by :math:`k[1] - k[0] + 1` .
The diagonal.shape[-1] must be
equal to the longest diagonal value `max_diag_len` calculated
by :math:`min(x.shape[-2] + min(k[1], 0), x.shape[-1] + min(-k[0], 0))` .
Let x have r + 1 dimensions [I, J, ..., L, M, N].
The diagonal tensor has rank r with shape :math:`[I, J, ..., L, max_diag_len]`
when k is an integer or :math:`k[0] == k[1]` . Otherwise, it has rank r + 1
with shape :math:`[I, J, ..., L, num_diags, max_diag_len]` .
Args:
align (string): An optional string from: "RIGHT_LEFT"(default), "LEFT_RIGHT", "LEFT_LEFT", "RIGHT_RIGHT". Align
is a string specifying how superdiagonals and subdiagonals should be aligned, respectively. "RIGHT_LEFT"
aligns superdiagonals to the right (left-pads the row) and subdiagonals to the left (right-pads the row).
align (str, optional): An optional string from: "RIGHT_LEFT", "LEFT_RIGHT", "LEFT_LEFT", "RIGHT_RIGHT".
Align is a string specifying how superdiagonals and subdiagonals should be aligned, respectively.
Default: "RIGHT_LEFT".
- "RIGHT_LEFT" aligns superdiagonals to the right (left-pads the row) and subdiagonals to the left
(right-pads the row).
- "LEFT_RIGHT" aligns superdiagonals to the left (right-pads the row) and subdiagonals to the right
(left-pads the row).
- "LEFT_LEFT" aligns superdiagonals to the left (right-pads the row) and subdiagonals to the left
(right-pads the row).
- "RIGHT_RIGHT" aligns superdiagonals to the right (left-pads the row) and subdiagonals to the right
(left-pads the row).
Inputs:
- **x** (Tensor) - Rank r + 1, where r >= 1.
@ -1368,14 +1380,14 @@ class MatrixSetDiagV3(Primitive):
Otherwise, it has rank r + 1.
- **k** (Tensor) - A Tensor of type int32. Diagonal offset(s). Positive value means superdiagonal, 0 refers to
the main diagonal, and negative value means subdiagonals. k can be a single integer (for a single diagonal) or
a pair of integers specifying the low and high ends of a matrix band. k[0] must not be larger than k[1]. The
value of k has restructions, meaning value of k must be in (-x.shape[-2], x.shape[-1]). Input k must be const
Tensor when taking Graph mode.
a pair of integers specifying the low and high ends of a matrix band. `k[0]` must not be larger than `k[1]` .
The value of `k` has restructions, meaning value of k must be in (-x.shape[-2], x.shape[-1]).
Input k must be const Tensor when taking Graph mode.
Outputs:
A Tensor. Has the same type as x.
Let x has r+1 dimensions [I, J, ..., L, M, N].
The output is a tensor of rank r+1 with dimensions [I, J, ..., L, M, N], the same as input x.
Tensor. The same type as x.
Let x has r+1 dimensions :math:`[I, J, ..., L, M, N]` .
The output is a tensor of rank r+1 with dimensions :math:`[I, J, ..., L, M, N]` , the same as input x.
Raises:
TypeError: If any input is not Tensor.
@ -1385,13 +1397,13 @@ class MatrixSetDiagV3(Primitive):
ValueError: If rank of `k` is not equal to 0 or 1.
ValueError: If rank of `x` is not greater equal to 2.
ValueError: If size of `k` is not equal to 1 or 2.
ValueError: If k[1] is not greater equal to k[0] in case the size of `k` is 2.
ValueError: If `k[1]` is not greater equal to `k[0]` in case the size of `k` is 2.
ValueError: If the `diagonal` rank size don't match with input `x` rank size.
ValueError: If the `diagonal` shape value don't match with input `x` shape value.
ValueError: If the diagonal.shape[-2] is not equal to num_diags calculated by k[1] - k[0] + 1.
ValueError: If the diagonal.shape[-2] is not equal to num_diags calculated by :math:`k[1] - k[0] + 1` .
ValueError: If the value of `k` is not in (-x.shape[-2], x.shape[-1]).
ValueError: If the diagonal.shape[-1] is not equal to the max_diag_len calculated by min(x.shape[-2] + min(k[1],
0), x.shape[-1] + min(-k[0], 0)).
ValueError: If the diagonal.shape[-1] is not equal to the max_diag_len calculated by
:math:`min(x.shape[-2] + min(k[1], 0), x.shape[-1] + min(-k[0], 0))` .
Supported Platforms:
``GPU`` ``CPU``
@ -7225,24 +7237,6 @@ class IndexFill(Primitive):
Refer to :func:`mindspore.ops.index_fill` for more details.
Inputs:
- **x** (Tensor) - Input tensor.
The shape is :math:`(N,*)` where :math:`*` means, any number of additional dimensions.
- **dim** (Union[int, Tensor]) - Dimension along which to fill the input tensor. Only supports
a 0-D tensor or an int number.
- **index** (Tensor) - Indices of the input tensor to fill in. Only supports a 0-D or 1-D tensor.
- **value** (Tensor) - Value to fill the returned tensor. Only supports a 0-D tensor or a scalar.
Outputs:
Tensor, has the same type and shape as input tensor.
Raises:
TypeError: If `x` is not a Tensor.
TypeError: If `dim` is neither a int number nor a tensor.
TypeError: If `index` is not a Tensor.
TypeError: If `value` is not a Tensor/Scalar.
TypeError: If dtype of `index` is not int32.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``

View File

@ -68,30 +68,10 @@ class Geqrf(Primitive):
class Svd(Primitive):
"""
Computes the singular value decompositions of one or more matrices.
Refer to :func:`mindspore.ops.svd` for more details.
Args:
full_matrices (bool, optional): If true, compute full-sized :math:`U` and :math:`V`. If false, compute
only the leading P singular vectors. P is the minimum of M and N.
M, N is the row, col of the input matrix. Default: False.
compute_uv (bool, optional): If true, compute the left and right singular vectors.
If false, compute only the singular values. Default: True.
Inputs:
- **a** (Tensor): Tensor of the matrices to be decomposed. The shape should be :math:`(*, M, N)`.
Outputs:
- **s** (Tensor) - Singular values. The shape is :math:`(*, P)`.
- **u** (Tensor) - Left singular vectors. If compute_uv is False, u will be an empty tensor.
The shape is :math:`(*, M, P)`. If full_matrices is True, the shape will be :math:`(*, M, M)`.
- **v** (Tensor) - Right singular vectors. If compute_uv is False, v will be an empty tensor.
The shape is :math:`(*, N, P)`. If full_matrices is True, the shape will be :math:`(*, N, N)`.
Raises:
TypeError: If full_matrices or compute_uv is not the type of bool.
TypeError: If the rank of input less than 2.
TypeError: If the type of input is not one of the following dtype: mstype.float32, mstype.float64.
Supported Platforms:
``GPU``

View File

@ -6175,24 +6175,6 @@ class MatrixExp(Primitive):
Refer to :func:`mindspore.ops.matrix_exp` for more details.
.. math::
matrix\_exp(x) = \sum_{k=0}^{\infty} \frac{1}{k !} x^{k} \in \mathbb{K}^{n \times n}
Inputs:
- **x** (Tensor) - The shape of tensor is :math:`(*, n, n)` where * is zero or more batch dimensions.
Must be one of the following types: float64, float32, float16, complex64, complex128.
Outputs:
Tensor, has the same shape and dtype as the `x`.
Raises:
TypeError: If `x` is not a Tensor.
TypeError: If the dtype of `x` is not one of the following dtype:
float16, float32, float64, complex64, complex128.
ValueError: If the rank of `x` is less than 2.
ValueError: If the last two dimensions of `x` are not equal.
Supported Platforms:
``Ascend`` ``CPU``
@ -7124,8 +7106,8 @@ class FFTWithSize(Primitive):
- "ortho" has both direct and inverse transforms are scaled by 1/sqrt(n).
- "forward" has the direct transforms scaled by 1/n and the inverse transforms unscaled.
onesided (bool): Controls whether the input is halved to avoid redundancy. Default: True.
signal_sizes (list): Size of the original signal (the signal before rfft, no batch dimension),
onesided (bool, optional): Controls whether the input is halved to avoid redundancy. Default: True.
signal_sizes (list, optional): Size of the original signal (the signal before rfft, no batch dimension),
only in irfft mode and set onesided=true requires the parameter. Default: [].
Inputs:

View File

@ -8992,54 +8992,10 @@ class ApplyAdamWithAmsgrad(Primitive):
class GridSampler3D(Primitive):
"""
Given an `input_x` and a flow-field `grid`, computes the `output` using `input_x` values and pixel locations from
`grid`. Only volumetric (5-D) `input_x` is supported.
Given an input and a grid, the output is calculated using the input values
and pixel positions in the grid. Only volume (5-D) input is supported.
For `input_x` with shape :math:`(N, C, D_{in}, H_{in}, W_{in})` and `grid` with shape :math:`(N, D_{out}, H_{out},
W_{out}, 3)`, the `output` will have shape :math:`(N, C, D_{out}, H_{out}, W_{out})`.
For each output location `output[n, :, d, h, w]`, the size-3 vector `grid[n, d, h, w]` specifies `input_x` pixel
locations x, y, z, which are used to interpolate the output value `output[n, :, d, h, w]`. And `interpolation_mode`
argument specifies "nearest" or "bilinear" interpolation method to sample the input pixels.
`grid` specifies the sampling pixel locations normalized by the `input_x` spatial dimensions. Therefore, it should
have most values in the range of :math:`[-1, 1]`.
If `grid` has values outside the range of :math:`[-1, 1]`, the corresponding outputs are handled as defined by
`padding_mode`. If `padding_mode` is set to be "zeros", use :math:`0` for out-of-bound grid locations. If
`padding_mode` is set to be "border", use border values for out-of-bound grid locations. If `padding_mode` is set
to be "reflection", use values at locations reflected by the border for out-of-bound grid locations. For location
far away from the border, it will keep being reflected until becoming in bound.
Args:
interpolation_mode (str): An optional string specifying the interpolation method. The optional values are
"bilinear" or "nearest". Default: "bilinear".
padding_mode (str): An optional string specifying the pad method. The optional values are "zeros", "border" or
"reflection". Default: "zeros".
align_corners (bool): An optional bool. If set to `True`, the extrema (-1 and 1) are considered as referring to
the center points of the inputs corner pixels. If set to `False`, they are instead considered as referring
to the corner points of the inputs corner pixels, making the sampling more resolution agnostic. Default:
`False`.
Inputs:
- **input_x** (Tensor) - A 5-D tensor with dtype of float32 or float64 and shape of :math:`(N, C, D_{in},
H_{in}, W_{in})`.
- **grid** (Tensor) - A 5-D tensor whose dtype is the same as `input_x` and whose shape is :math:`(N, D_{out},
H_{out}, W_{out}, 3)`.
Outputs:
A 5-D Tensor whose dtype is the same as `input_x` and whose shape is :math:`(N, C, D_{out}, H_{out}, W_{out})`.
Raises:
TypeError: If `input_x` or `grid` is not a Tensor.
TypeError: If the dtypes of `input_x` and `grid` are inconsistent.
TypeError: If the dtype of `input_x` or `grid` is not a valid type.
TypeError: If `align_corners` is not a boolean value.
ValueError: If the rank of `input_x` or `grid` is not equal to 5.
ValueError: If the first dimension of `input_x` is not equal to that of `grid`.
ValueError: If the last dimension of `grid` is not equal to 3.
ValueError: If `interpolation_mode` is not "bilinear", "nearest" or a string value.
ValueError: If `padding_mode` is not "zeros", "border", "reflection" or a string value.
Refer to :func:`mindspore.ops.grid_sample` for more details.
Supported Platforms:
``Ascend`` ``GPU`` ``CPU``