[object Object][object Object][object Object]undefined
[object Object]
  • Description: Implements the backward propagation of to complete the weighted summation of tokens.
  • Formula:gradXi=t=0topKgradExpandedX[expandedRowIdx[itopK+t]]gradX_i=\sum_{t=0}^{topK}gradExpandedX[expandedRowIdx[i * topK + t]]
[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): target tensor after routing. It must be a 2D or 3D tensor. The 2D shape is [B*S*K, H] in the dropless scenario or [A, H] in the active scenario. The 3D shape is [E, C, H] in the drop/pad scenario. The data type can be FLOAT16, BFLOAT16, or FLOAT32. The must be ND. are supported.

    • [object Object] (aclTensor*, computation input): tokens are indexed in expert order. It is a 1D tensor with shape [B*S*K]. The value range is [-1, E*C) in the drop/pad scenario and [0, B*S*K) in other scenarios. The value is unique except [object Object]. The data type can be INT32. The must be ND. are supported.

    • [object Object] (int64_t, computation input): an integer on the host. The value must be greater than [object Object] and exactly divisible by the size of axis 0 of [object Object].

    • [object Object] (int64_t, computation input): indicates whether the scenario is in drop mode. It is an integer on the host. The value range is [0, 1]. [object Object] indicates the dropless scenario, and [object Object] indicates the drop/pad scenario.

    • [object Object] (int64_t, computation input): indicates whether the active scenario is involved. It is an integer on the host. The value range is greater than or equal to [object Object]. This parameter is valid when [object Object] is set to [object Object], indicating the non-active scenario, and a value greater than 0 indicates the active scenario. In the active scenario, the size of axis 0 of [object Object] must be equal to the value of [object Object].

    • [object Object] (aclTensor*, computation output): backward output of routing. It is a 2D tensor with shape [B*S, H]. The data type can be FLOAT16, BFLOAT16, or FLOAT32. The output type is the same as that of [object Object]. The must be ND. are 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.

      Shape symbol description:

      [object Object]: batch size; [object Object]: number of tokens; [object Object]: hidden size, that is, the length of each token sequence; [object Object]: [object Object], that is, the number of experts that process tokens. [object Object]: [object Object] value; [object Object]: number of experts; [object Object]: expert capacity, that is, the number of tokens that can be processed by an expert.

  • 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]

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

[object Object]