Description: Performs backpropagation of
[object Object].Formula: R: batch × sequence
H: hidden
K: topK
gradY: (R, H)
expandedRowIdx: (R × K)
expandedXOptional: (R × K, H) or (activeNum, H) or (expertNum, expertCapacity, H)
scalesOptional: (R, K)
expertIdxOptional: (R, K)
biasOptional: (E, H)
i : 0 ~ R × K - 1
j : 0 ~ H
(1)
[object Object]is a null pointer:(2)
[object Object]is not a null pointer, and[object Object]is a null pointer:(3)
[object Object]and[object Object]are not null pointers:
Each operator consists of . You must first call the [object Object] API to obtain the required workspace size and the executor that contains the operator computation flow, and then call the [object Object] API to execute the computation.
[object Object][object Object]
Parameters:
[object Object](aclTensor*, computation input):[object Object]on the device, derivative of the forward output y of[object Object]. It must be a 2D tensor with shape (R, H). The data type can be FLOAT16, BFLOAT16, or FLOAT32. The must be ND. Non-contiguous input is supported.[object Object](aclTensor*, computation input):[object Object]on the device, indicating the token index sorted by expert sequence. It must be a 1D tensor with shape (R × K). When[object Object]is set to a null pointer,[object Object]must be 1. When[object Object]is 0, the value range is [0, R* K – 1] and no duplicate index is allowed. When[object Object]is 1, the value range is [–1, expertNum * expertCapacity – 1] and no duplicate index except –1 is allowed. The data type is INT32. The must be ND. Non-contiguous input is supported.[object Object](aclTensor*, optional computation input):[object Object]on the device, indicating the features extended based on[object Object]. When[object Object]is not a null pointer, this parameter cannot be a null pointer either. When[object Object]is 0, it must be a 2D tensor. When[object Object]is greater than 0 and less than R × K, the shape is (activeNum, H). Otherwise, the shape is (R × K, H). When[object Object]is 1, it must be a 3D tensor with shape (expertNum, expertCapacity, H). The data type is the same as that of[object Object]. The supported data types are FLOAT16, BFLOAT16, and FLOAT32. The must be ND. Non-contiguous input is supported.[object Object](aclTensor*, optional computation input):[object Object]on the device, indicating the feature scaling. It must be a 2D tensor with shape (R, K). The data type can be FLOAT16, BFLOAT16, or FLOAT32. The must be ND. Non-contiguous input is supported.- [object Object]Atlas A2 training products/Atlas A2 inference products[object Object] and [object Object]Atlas A3 training series products/Atlas A3 inference series products[object Object]: The data type must be the same as that of
[object Object].
- [object Object]Atlas A2 training products/Atlas A2 inference products[object Object] and [object Object]Atlas A3 training series products/Atlas A3 inference series products[object Object]: The data type must be the same as that of
[object Object](aclTensor*, optional computation input):[object Object]on the device, indicating the index of an expert that processes a feature. When[object Object]is a non-null pointer, the value cannot be a null pointer. It must be a 2D tensor with shape (R, K) and value range [0, E - 1], E ≥ 1, allowing duplicate indices. The data type is the same as that of[object Object]and can be INT32. The must be ND. Non-contiguous tensors are supported.[object Object](aclTensor*, optional computation input):[object Object]on the device, indicating the feature bias. It must be a 2D tensor with shape (E, H). The data type is the same as that of[object Object]and can be FLOAT16, BFLOAT16, or FLOAT32. The must be ND. Non-contiguous input is supported.[object Object](int64_t, computation input): int64 data type, indicating different scenarios. The value can be 0 or 1. 0 indicates the dropless scenario, where[object Object]and[object Object]are not verified. 1 indicates the drop scenario, where[object Object]and[object Object]need to be verified. The values exceeding or below[object Object]will be processed accordingly.[object Object](int64_t, computation input): int64 data type, indicating the maximum number of rows in[object Object]. When[object Object]is 0, this parameter takes effect only when[object Object]is greater than 0 and less than R × K. When[object Object]is 1, this parameter does not take effect.[object Object](int64_t, computation input): int64 data type, indicating the number of experts. When[object Object]is 0, this parameter does not take effect. When[object Object]is 1 and[object Object]is a non-null pointer, expertNum must be equal to E. When[object Object]is a null pointer,[object Object]must be greater than 0. Otherwise, an error is reported.[object Object](int64_t, computation input): int64 data type, indicating the number of rows that can be processed by each expert. When[object Object]is 0, this parameter does not take effect. When[object Object]is 1,[object Object]must be greater than 0. Otherwise, an error is reported.[object Object](aclTensor*, computation output):[object Object]on the device, indicating the derivative of the forward input[object Object]of[object Object]. When[object Object]is 0, it must be a 2D tensor. When[object Object]is greater than 0 and less than R × K, the shape is (activeNum, H). Otherwise, the shape is (R × K, H). When[object Object]is 1, it must be a 3D tensor. The shape is (expertNum, expertCapacity, H). The data type is the same as that of[object Object]. The data type can be FLOAT16, BFLOAT16, or FLOAT32. The must be ND. Non-contiguous output is not supported.[object Object](aclTensor*, computation output):[object Object]on the device, indicating the derivative of the forward input scales of[object Object]. The output is valid only when[object Object]is not a null pointer. The output must be a 2D tensor with shape (R, K). The data type is the same as that of[object Object]and can be FLOAT16, BFLOAT16, or FLOAT32. The must be ND. Non-contiguous input is not supported.[object Object](uint64_t*, output): size of the workspace to be allocated on the device.[object Object](aclOpExecutor**, output): operator executor, covering the operator computation process.
Returns:
[object Object]status code. For details, see .[object Object]
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[object Object].[object Object](aclOpExecutor*, input): operator executor, covering the operator computation process.[object Object](aclrtStream, input): stream for executing the task.
Returns:
- Deterministic computing:
[object Object]defaults to a deterministic implementation.
The following example is for reference only. For details, see .