[object Object]

[object Object][object Object]undefined
[object Object]
  • API function: performs backpropagation of aclnnMoeTokenUnpermute.

  • Formulas:

    • If [object Object] is not set to [object Object]:

      unpermutedTokens[i]=permutedTokens[sortedIndices[i]]unpermutedTokens[i] = permutedTokens[sortedIndices[i]] unpermutedTokens=unpermutedTokens.reshape(1,topK_num,hiddenSize)unpermutedTokens = unpermutedTokens.reshape(-1, topK\_num, hiddenSize) unpermutedTokens=unpermutedTokensGrad.unsqueeze(1)unpermutedTokensunpermutedTokens = unpermutedTokensGrad.unsqueeze(1) * unpermutedTokens probsGrad=k=0K(unpermutedTokensi,j,k)probsGrad = \sum_{k=0}^{K}(unpermutedTokens_{i,j,k}) permutedTokensGrad[sortedIndices[i]]=((unpermutedTokensGrad.unsqueeze(1)probs.unsqueeze(1)).reshape(1,hiddenSize))[i]permutedTokensGrad[sortedIndices[i]] = ((unpermutedTokensGrad.unsqueeze(1) * probs.unsqueeze(-1)).reshape(-1, hiddenSize))[i]
    • If [object Object] is set to [object Object]:

      permutedTokensGrad[sortedIndices[i]]=unpermutedTokensGrad[i]permutedTokensGrad[sortedIndices[i]] = unpermutedTokensGrad[i]
[object Object]

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]
[object Object]
  • 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]
[object Object]
  • Parameters

    [object Object]
  • Returns:

    [object Object]: status code. For details, see .

[object Object]
  • Deterministic computation:
    • [object Object] defaults to deterministic implementation.
  • tokens_num indicates the number of input tokens, and hidden_size indicates the dimension of the word vector.
  • The following two modes are distinguished by the paddedMode parameter. When paddedMode is set to true, each expert can process a fixed number of tokens (capacity). When [object Object] is set to [object Object], each token is processed by a fixed number of experts, which is specified by [object Object].
  • [object Object]Atlas A2 training products/Atlas A2 inference products[object Object] and [object Object]Atlas A3 training products/Atlas A3 inference products[object Object]: The value of [object Object] is less than or equal to [object Object].
  • Ascend 950PR/Ascend 950DT: When this API is called, the framework internally calls the API. If a parameter error message is displayed, refer to the following parameter mapping:
    • The permutedTokens input is equivalent to the expandedXOptional input of the aclnnMoeFinalizeRoutingV2Grad API.
    • The unpermutedTokensGrad input is equivalent to the gradY input of the aclnnMoeFinalizeRoutingV2Grad API.
    • The sortedIndices input is equivalent to the expandedRowIdx input of the aclnnMoeFinalizeRoutingV2Grad API.
    • The probsOptional input is equivalent to the scalesOptional input of the aclnnMoeFinalizeRoutingV2Grad API.
    • The paddedMode input is equivalent to the dropPadMode input of the aclnnMoeFinalizeRoutingV2Grad API.
    • The permutedTokensGradOut output is equivalent to the gradExpandedXOut output of the aclnnMoeFinalizeRoutingV2Grad API.
    • The probsGradOut output is equivalent to the gradScalesOut output of the aclnnMoeFinalizeRoutingV2Grad API.
[object Object]

The following example is for reference only. For details, see .

[object Object]