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

35 lines
1.6 KiB
ReStructuredText
Raw Permalink 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.MatMul
=====================
.. py:class:: mindspore.ops.MatMul(transpose_a=False, transpose_b=False)
将矩阵 `a` 和矩阵 `b` 相乘。
.. math::
(Output)_{i j}=\sum_{k=1}^{p} a_{i k} b_{k j}=a_{i 1} b_{1 j}+a_{i 2} b_{2 j}+\cdots+a_{i p} b_{p j}, p\in N
其中, :math:`i,j` 表示输出的第i行和第j列元素。
.. note::
-:math:`N * M` 不能被16整除时算子在Ascend环境上的性能会比较差。
- 输入Tensor的数据类型必须一致。
- Ascend上暂不支持float64类型。
参数:
- **transpose_a** (bool可选) - 如果为 ``True`` ,则在相乘之前转置 `a`。默认值: ``False``
- **transpose_b** (bool可选) - 如果为 ``True`` ,则在相乘之前转置 `b`。默认值: ``False``
输入:
- **a** (Tensor) - 要相乘的第一个Tensor。如果 `transpose_a```False`` 则该Tensor的shape为 :math:`(N, C)` 否则该Tensor的shape为 :math:`(C, N)`
- **b** (Tensor) - 要相乘的第二个Tensor。如果 `transpose_b```False`` 则该Tensor的shape为 :math:`(C, M)` 否则该Tensor的shape为 :math:`(M, C)`
输出:
Tensor输出Tensor的shape为 :math:`(N, M)`
异常:
- **TypeError** - `transpose_a``transpose_b` 不是bool。
- **TypeError** - `a` 的dtype和 `b` 的dtype不一致。
- **ValueError** - 矩阵 `a` 的列不等于矩阵 `b` 的行。
- **ValueError** - `a``b` 的维度不等于2。