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

30 lines
1.3 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.swiglu
====================
.. py:function:: mindspore.ops.swiglu(input, dim=-1)
计算Swish门线性单元函数Swish Gated Linear Unit function
SwiGLU是 :class:`mindspore.ops.GLU` 激活函数的变体,定义为:
.. math::
{SwiGLU}(a, b)= Swish(a) \otimes b
其中,:math:`a` 表示输入 `input` 拆分后Tensor的前一半元素:math:`b` 表示输入拆分Tensor的另一半元素
Swish(a)=a :math:`\sigma` (a):math:`\sigma`:func:`mindspore.ops.sigmoid` 函数, :math:`\otimes` 是Hadamard乘积。
.. warning::
只支持 `Atlas A2` 训练系列产品。
参数:
- **input** (Tensor) - 被分Tensorshape为 :math:`(\ast_1, N, \ast_2)` ,其中 `*` 为任意额外维度。 :math:`N` 必须能被2整除。
- **dim** (int可选) - 指定分割轴。数据类型为整型,默认 ``-1`` 输入input的最后一维。
返回:
Tensor数据类型与输入 `input` 相同shape为 :math:`(\ast_1, M, \ast_2)`,其中 :math:`M=N/2`
异常:
- **TypeError** - `input` 数据类型不是float16、float32或bfloat16。
- **TypeError** - `input` 不是Tensor。
- **RuntimeError** - `dim` 指定维度不能被2整除。