Description: Implements backward propagation of 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.
Formulas:
Backward propagation of LayerNorm:
Backward propagation of LayerNorm (with affine transformation parameters):
Where (μ is the mean value, and σ[object Object]2[object Object] is the variance):
Backward propagation of RoPE (Interleave):
Backward propagation of RoPE (Half):
Interleave() indicates that the odd and even positions in the headDim dimension are alternately rearranged, and Half() indicates that the second half and the first half of the elements in the headDim dimension are alternately rearranged. For example, if x = [0,1,2,3,4,5,6,7], then Interleave(x) = [1,0,3,2,5,4,7,6] and Half(x) = [4,0,5,1,6,2,7,3]. negMask is the length of headDim. The even bit is 1 and the odd bit is -1, that is, (1, -1, 1, -1, 1,...).
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]
- Deterministic computation:
[object Object]defaults to a non-deterministic implementation. You can call[object Object]to enable deterministic computation.