Description: Implements normalization (Norm), Rotary Position Embedding (RoPE), and feature concatenation (Concat) for
[object Object],[object Object], and[object Object]in the (multi-modal) transformer attention mechanism.- Currently, Norm supports layer normalization (LayerNorm) and layer normalization with affine transformation parameters (AFFINE LayerNorm).
- RoPE supports the Interleave and Half types.
- Concat can be performed in the sequence dimension with support for specifying different concatenation orders.
The computation formulas (using
[object Object](video) and[object Object](text) as examples) are as follows:Note:
The input and output layouts are as follows: The shape of the input
[object Object]is[object Object], and the shape of the output[object Object]is[object Object].[object Object]indicates[object Object],[object Object]indicates[object Object],[object Object]indicates[object Object], and[object Object]indicates[object Object].LayerNorm has three modes (specified by
[object Object]):[object Object],[object Object], and[object Object]. When[object Object]:When
[object Object]:When
[object Object](based on the preceding formulas):Concat is performed in the sequence dimension. The concatenation order is specified by
[object Object]. When[object Object], is before . When[object Object], is after .RoPE has three modes (specified by
[object Object]):[object Object],[object Object], and[object Object]. When[object Object], the output is directly generated without transformation. In other cases, see the following:[object Object]The shape of the input
[object Object]for RoPE is[object Object], whereIn the training scenario,
[object Object],[object Object],[object Object], and[object Object]are output for subsequent backward propagation.
Each operator has calls. First, [object Object] is called to obtain the input parameters and compute the required workspace size based on the process. Then, [object Object] is called to perform computation.
Parameters
[object Object]Returns
[object Object]: status code. For details, see .The first-phase API implements input parameter verification. The following errors may be thrown.
[object Object]
- The data types of
[object Object],[object Object],[object Object],[object Object],[object Object], and[object Object]must be the same. - The value of
[object Object]must be an even number in the range of [1, 1024]. - The value of
[object Object]must be in the range of [1, Min([object Object]+[object Object],[object Object]+[object Object])].
The following example is for reference only. For details, see .