mindspore/docs/api/api_python/ops/mindspore.ops.func_diag.rst

19 lines
659 B
ReStructuredText
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

mindspore.ops.diag
===================
.. py:function:: mindspore.ops.diag(input_x)
用给定的对角线值构造对角线Tensor。
假设输入Tensor维度为 :math:`[D_1,... D_k]` 则输出是一个rank为2k的tensor其维度为 :math:`[D_1,..., D_k, D_1,..., D_k]` ,其中 :math:`output[i_1,..., i_k, i_1,..., i_k] = input_x[i_1,..., i_k]` 并且其他位置的值为0。
参数:
- **input_x** (Tensor) - 输入Tensor。
返回:
Tensor具有与输入Tensor相同的数据类型。
异常:
- **TypeError** - `input_x` 不是Tensor。
- **ValueError** - `input_x` 的rank小于1。