[object Object][object Object][object Object]undefined
[object Object]
  • Description: Computes the backpropagation of [object Object].

  • Formula:

    (1) When [object Object] is not set to [object Object]:

    permutedTokensGrad[outIndex[i]]=unpermutedTokensGrad[permuteTokenId[i]]permutedTokensGrad[outIndex[i]] = unpermutedTokensGrad[permuteTokenId[i]] permutedProbsGrad=permutedTokensGradpermutedTokensOptionalpermutedProbsGrad = permutedTokensGrad * permutedTokensOptional probsGradExpertOrder=j=0hidden_size(permutedProbsGradi,j)probsGradExpertOrder = \sum_{j=0}^{hidden\_size}(permutedProbsGrad_{i,j})
    • When [object Object] is set to [object Object]:
    probsGradOut=masked_scatter(routingMapOptionalT,probsGradExpertOrder)probsGradOut = masked\_scatter(routingMapOptional^T,probsGradExpertOrder) permutedProbs=probsOptionalT.masked_select(routingMapOptionalT)permutedProbs = probsOptional^T.masked\_select(routingMapOptional^T) permutedTokensGradOut=permutedProbs.unsqueeze(1)permutedTokensGradpermutedTokensGradOut = permutedProbs.unsqueeze(-1) * permutedTokensGrad
    • When [object Object] is set to [object Object]:
    probsGradOut[permuteTokenId[i],outIndex[i]/capacity]=probsGradExpertOrder[outIndex[i]]probsGradOut[permuteTokenId[i], outIndex[i]/capacity] = probsGradExpertOrder[outIndex[i]] permutedProbs[outIndex[i]]=probsOptional.view(1)[i]permutedProbs[outIndex[i]] = probsOptional.view(1)[i] permutedTokensGradOut=permutedProbspermutedTokensGradpermutedTokensGradOut = permutedProbs * permutedTokensGrad

    (2) When [object Object] is set to [object Object]:

    permutedTokensGradOut[outIndex[i]]=unpermutedTokensGrad[permuteTokenId[i]]permutedTokensGradOut[outIndex[i]] = unpermutedTokensGrad[permuteTokenId[i]]
    1. [object Object] indicates the size of the first dimension of [object Object].
    2. When [object Object] is set to [object Object], each expert can process a fixed number of tokens, which is specified by [object Object]. The first dimension of the input [object Object] is the value specified by [object Object], which indicates the number of experts. The 0th dimension of the input [object Object] is [object Object] * [object Object]. The value of [object Object] can be computed based on the two dimensions.
    3. When [object Object] is set to [object Object], each token is processed by a fixed number of experts, which is specified by [object Object]. The 0th dimension of the input [object Object] is specified by [object Object], which indicates the number of tokens. The 0th dimension of the input [object Object] is the value specified by [object Object] * [object Object]. The value of [object Object] can be computed based on the two dimensions.
[object Object]

Each operator has calls. First, [object Object] is called to obtain the workspace size required for computation and the executor covering 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.
  • When the input [object Object] is not left empty and [object Object] is set to [object Object], the value of [object Object] is less than or equal to that of [object Object], and the value is less than or equal to [object Object].

  • When the input [object Object] is not left empty and [object Object] is set to [object Object], the value of [object Object] is less than or equal to that of [object Object].

[object Object]

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

[object Object]