!45537 add document of DiagPart

Merge pull request !45537 from yangshuo/code_docs_api
This commit is contained in:
i-robot 2022-11-14 12:55:43 +00:00 committed by Gitee
commit 62b3829598
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 24 additions and 1 deletions

View File

@ -427,6 +427,7 @@ Array操作
mindspore.ops.CumSum
mindspore.ops.DataFormatDimMap
mindspore.ops.DepthToSpace
mindspore.ops.DiagPart
mindspore.ops.DType
mindspore.ops.ExpandDims
mindspore.ops.FloatStatus

View File

@ -0,0 +1,21 @@
mindspore.ops.DiagPart
======================
.. py:class:: mindspore.ops.DiagPart
返回输入的对角线部分。
假如`input_x`有维度`[D_1,..., D_k, D_1,..., D_k]`那么输出是一个秩为k的Tensor维度为`[D_1,..., D_k]`,其中:
`output[i_1,..., i_k] = input_x[i_1,..., i_k, i_1,..., i_k]`
输入:
- **input_x** (Tensor) - 输入Tensor。它的秩为`k(k > 0)`
输出:
Tensor`input` 有相同的数据类型。
异常:
- **TypeError** - 如果 `input` 不是Tensor。
- **ValueError** - 如果 `input` 的秩不是偶数,或为零。
- **ValueError** - 如果 `input` 的shape不满足`input_shape[i] == input_shape[i + len(input_shape)/2]`

View File

@ -427,6 +427,7 @@ Array Operation
mindspore.ops.CumSum
mindspore.ops.DataFormatDimMap
mindspore.ops.DepthToSpace
mindspore.ops.DiagPart
mindspore.ops.DType
mindspore.ops.ExpandDims
mindspore.ops.FloatStatus

View File

@ -3533,7 +3533,7 @@ class DiagPart(PrimitiveWithCheck):
:math:`output[i_1,..., i_k] = input[i_1,..., i_k, i_1,..., i_k]`.
Inputs:
- **input_x** (Tensor) - The input tensor of rank 2k, k is not zero.
- **input_x** (Tensor) - The rank of input tensor is 2k(k > 0).
Outputs:
Tensor, the extracted diagonal has the same dtype as the `input_x`.