Function: Performs the backward computation of the single-channel rotary position embedding .
Formula:
If the broadcast axis list in the forward computation of the rotary position embedding is
[object Object], the calculation formula is as follows:- [object Object]Atlas A3 training products/Atlas A3 inference products[object Object] and [object Object]Atlas A2 training products/Atlas A2 inference products[object Object]:
(1) half mode (mode = 0):
(2) Interleave mode (mode = 1):
(3) Quarter mode (mode = 2):
(4) Interleave-half mode (mode = 3):
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]- Constraints:
- [object Object]Atlas A3 training products/Atlas A3 inference products[object Object] and [object Object]Atlas A2 training products/Atlas A2 inference products[object Object]: 0=half, 1=interleave.
- Ascend 950PR/Ascend 950DT: 2=quarter, 3=interleave-half.
- Constraints:
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 deterministic implementation.Ascend 950PR/Ascend 950DT:
The input tensor x has four dimensions. The shape constraints of each parameter are as follows:
- The last dimension of the input tensor x, cos, sin, and output tensor y must be the same and less than or equal to 1024. In half, interleave, and interleave-half modes, the last dimension must be exactly divisible by 2. In quarter mode, the last dimension must be exactly divisible by 4.
- The shape of the input tensor x must be the same as that of the output tensor y.
- The shapes of the input tensors cos and sin must be the same. The shapes of cos and sin must meet the with x, and the shape after broadcasting must be the same as the shape of x.
[object Object]Atlas A3 training products/Atlas A3 inference products[object Object] and [object Object]Atlas A2 training products/Atlas A2 inference products[object Object]:
- The input tensor dy supports the BNSD, BSND, SBND, and TND layouts.
- The D dimension of the input tensors dy, cos, sin, and xOptional and the output tensors dxOut, dcosOut, and dsinOut must be the same, and the value must be less than 896 and a multiple of 2.
- The shape of the input tensor dy and xOptional must be the same as that of the output tensor dxOut.
- The shape of the input tensors cos and sin must be the same as that of the output tensors dcosOut and dsinOut, respectively. In addition, the shape of cos must be the same as that of sin.
- half mode:
- B, N < 1000. When dsin and dcos need to be computed, B x N <= 1024.
- When dy is in BNSD format, cos and sin support 11SD, B1SD, and BNSD. When cos and sin are in B1SD format, B < S must be met.
- When dy is in BSND format, cos and sin support 1S1D, BS1D, and BSND. When cos and sin are in BS1D format, B < S must be met.
- When dy is in SBND format, cos and sin support S11D, SB1D, and SBND.
- When dy is in TND format, cos and sin support T1D and TND.
- Interleave mode:
- B x N < 1000 (N < 1000 when dy is in TND format)
- When dy is in BNSD format, cos and sin support 11SD.
- When dy is in BSND format, cos and sin support 1S1D.
- When dy is in SBND format, cos and sin support S11D.
- When dy is in TND format, cos and sin support T1D.
The following example is for reference only. For details, see .