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

  • Formula:

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

      unpermutedTokens[i]=permutedTokens[sortedIndices[i]]unpermutedTokens[i] = permutedTokens[sortedIndices[i]] unpermutedTokens=unpermutedTokens.reshape(1,topK,hiddenSize)unpermutedTokens = unpermutedTokens.reshape(-1, topK, 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]]=unpermutedOutputGrad[i]permutedTokensGrad[sortedIndices[i]] = unpermutedOutputGrad[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] (aclTensor*, computation input): aclTensor on the device, which indicates an input token. The value must be a 2D tensor with shape (tokens_num * topK_num, hidden_size). The data type can be BFLOAT16, FLOAT16, 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 products/Atlas A3 inference products[object Object]: The value of [object Object] is less than or equal to [object Object].
    • [object Object] (aclTensor*, computation input): aclTensor on the device, which indicates the gradient of the forward output [object Object]. The value must be a 2D tensor with shape (tokens_num, hidden_size). The data type is the same as that of [object Object] and can be BFLOAT16, FLOAT16, or FLOAT32. The must be ND. Non-contiguous input is supported.
    • [object Object] (aclTensor*, computation input): aclTensor on the device. The value must be a 1D shape with size (tokens_num * topK_num,). The data type can be INT32. The must be ND. The value range is [0, tokens_num * topK_num – 1], and there is no duplicate index. Non-contiguous input is supported.
    • [object Object] (aclTensor*, computation input): aclTensor on the device. This input is optional. The value must be a 2D shape with size (tokens_num, topK_num). 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]. Non-contiguous input is supported.
    • [object Object] (bool, computation input): [object Object] indicates that [object Object] is enabled, and [object Object] indicates that [object Object] is disabled. For details about [object Object], see the [object Object] parameter. Currently, only [object Object] is supported.
    • [object Object] (aclIntArray*, computation input): 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] (aclTensor*, computation output): gradient of the input [object Object]. The value must be a 2D tensor with shape (tokens_num * topK_num, 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*, output): gradient of the input [object Object]. This output is optional. The value must be a 2D tensor with shape (tokens_num, topK_num). 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:

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

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

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

[object Object]
  • Deterministic computation:
    • [object Object] defaults to deterministic implementation.
  • [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].
[object Object]

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

[object Object]