Description: Computes the backpropagation of
[object Object].Formula:
If
[object Object]is not set to[object Object], the formula is as follows, where :First, calculate
[object Object].When the condition rangeOptional[0] ≤ sortedIndices[i] < rangeOptional[1] is met,
Otherwise,
Then, compute the following:
Finally, when the condition rangeOptional[0] ≤ sortedIndices[i] < rangeOptional[1] is met,
If
[object Object]is set to[object Object], the formula is as follows, where :- When the condition rangeOptional[0] ≤ sortedIndices[i] < rangeOptional[1] is met,
Each operator has calls. First, [object Object] is called to obtain the workspace size required for computation and the executor that contains the operator computation process. Then, [object Object] is called to perform computation.
[object Object][object Object]
Parameters:
[object Object](aclTensor*, computation input): aclTensor on the device, that is,[object Object]in the formula. It indicates the gradient of the forward output[object Object]. The value must be a 2D tensor with shape (tokens_num, hidden_size).[object Object]indicates the number of tokens, and[object Object]indicates the token dimension size. The data type can be BFLOAT16, FLOAT16, or FLOAT32. The must be ND. are supported.[object Object](aclTensor*, computation input): aclTensor on the device, that is,[object Object]in the formula. The value must be a 1D shape with size (tokens_num * topkNum). The data type can be INT32. The must be ND. The index value range is [0, tokens_num * topkNum – 1]. are supported.[object Object](aclTensor*, computation input): aclTensor on the device, that is,[object Object]in the formula. This input is optional. The value must be a 2D tensor with shape (tokens_num * topkNum, hidden_size), where the value of[object Object]is less than or equal to[object Object]. The data type is the same as that of[object Object]. The must be ND. are supported.[object Object](aclTensor*, computation input): aclTensor on the device, that is,[object Object]in the formula. This input is optional. The value must be a 2D shape with size (tokens_num, topkNum). The data type can be BFLOAT16, FLOAT16, or FLOAT32. The must be ND. When[object Object]is passed, the value of[object Object]equals the second dimension of[object Object]. When[object Object]is not passed, the value of[object Object]is[object Object]. are supported.[object Object](bool, computation input):[object Object]in the formula. The value[object Object]indicates that[object Object]is enabled, and the value[object Object]indicates that[object Object]is disabled. For details about[object Object], see the description of the[object Object]parameter. Currently, only[object Object]is supported.[object Object](aclIntArray*, computation input):[object Object]in the formula. This parameter takes effect only when[object Object]is set to[object Object]. Otherwise, no operation is performed on this parameter. When[object Object]is set to[object Object], the shape is the same as that of[object Object]. Currently, only[object Object]is supported.[object Object](aclIntArray*, computation input):[object Object]in the formula, which indicates the valid range of EP slicing. The start position represented by[object Object]must be less than the end position represented by[object Object]. The size is[object Object]. This parameter does not take effect when it is left empty.[object Object](int64_t, computation input):[object Object]in the formula, which indicates the number of experts selected for each token.[object Object](aclTensor*, computation output): gradient of the input[object Object]. The value must be a 2D tensor with shape (tokens_num * topkNum, hidden_size). The data type is the same as that of[object Object]. The data type can be BFLOAT16, FLOAT16, or FLOAT32. The must be ND. Non-contiguous output is not supported.[object Object](aclTensor*, computation output): optional output, which is the gradient of the input[object Object]. The value must be a 2D tensor with shape (tokens_num, topkNum). The data type is the same as that of[object Object]. The data type can be BFLOAT16, FLOAT16, or FLOAT32. The must be ND. Non-contiguous output is not supported.[object Object](uint64_t *, output): size of the workspace to be allocated on the device.[object Object](aclOpExecutor **, output): operator executor, containing the operator computation process.
Returns:
Parameters:
[object Object](void*, input): address of the workspace to be allocated on the device.[object Object](uint64_t, input): size of the workspace to be allocated on the device, which is obtained by calling the first-phase API[object Object].[object Object](aclOpExecutor*, input): operator executor, containing the operator computation process.[object Object](aclrtStream, input): stream for executing the task.
Returns:
- Deterministic computation:
[object Object]defaults to deterministic implementation.
- The value of
[object Object]is less than or equal to[object Object].
The following example is for reference only. For details, see .