[object Object]

[object Object][object Object]undefined
[object Object]
  • Description: This operator is a part of the cross entropy computation module in the vocabulary parallelism scenario. It solves the video memory and computing efficiency problems in the case of ultra-large vocabulary. This part involves the result of computing loss and softMax.

  • Formula:

    $$ lossOut = log(sum_exp_logits) - predicted_logits

    $$ $$ softMaxOutOptional = exp(vocab_parallel_logits -logits_max.unsqueeze(dim = -1)) \ sum_exp_logits.unsqueeze(dim = -1) $$
[object Object]

Each operator has calls. First, aclnnFusedCrossEntropyLossWithMaxSumGetWorkspaceSize is called to obtain the workspace size required for computation and the executor that contains the operator computation process. Then, aclnnFusedCrossEntropyLossWithMaxSum is called to perform computation.

  • [object Object]
  • [object Object]
[object Object]
  • Parameters:

    • logitsMax (aclTensor*, computation input): logitsMax in the formula, maximum value of each row after matmul computation, and aclTensor on the device. are supported. The can be ND. The shape can be 1D and the data type can be FLOAT.

    • sumExpLogits (aclTensor*, computation input): sumExpLogits in the formula, exp result obtained from the difference between the matmul computation result and the maximum value of each row, and aclTensor on the device. are supported. The can be ND. The shape can be 1D and is the same as that of logitsMax, and the data type can be FLOAT.

    • predictedLogits (aclTensor*, computation input): predictedLogits in the formula, result filtered by maskedTargetOut after the difference between the matmul computation result and the maximum value of each row is calculated, and aclTensor on the device. are supported. The can be ND. The shape can be 1D and is the same as that of logitsMax, and the data type can be FLOAT.

    • labelSmoothing (float, computation input): label smoothing coefficient, which is used to alleviate overfitting. Currently, only value 0 is supported.

    • inputOptional (aclTensor*, computation input): left matrix of the matmul input and aclTensor on the device. are supported. The can be ND. Currently, only null pointers are supported.

    • weightOptional (aclTensor*, computation input): weight matrix, right matrix of the matmul input, and aclTensor on the device. are supported. The can be ND. Currently, only null pointers are supported.

    • vocabParallelLogitsOptional (aclTensor*, computation input): vocabParallelLogits in the formula, matmul computation result, and aclTensor on the device. are supported. The can be ND. The shape can be 2D. The first dimension of the shape must be the same as that of logitsMax. The data type can be FLOAT16 or BFLOAT16.

    • lossOut (aclTensor*, computation output): loss in the formula, intermediate variable, and aclTensor on the device. The shape is the same as that of logitsMax. The can be ND, and the data type can be FLOAT.

    • softMaxOutOptional (aclTensor*, computation output): vocabParallelLogits in the formula, intermediate variable, and aclTensor on the device. The shape is the same as that of vocabParallelLogitsOptional. The can be ND, and the data type can be FLOAT.

    • workspaceSize (uint64_t*, output): size of the workspace to be allocated on the device.

    • executor (aclOpExecutor**, output): operator executor, containing the operator computation process.

  • Returns:

    aclnnStatus: status code. For details, see .

[object Object]
[object Object]
  • Parameters:

    • workspace (void*, input): address of the workspace to be allocated on the device.

    • workspaceSize (uint64_t, input): workspace size allocated on the device, which is obtained by the first-phase API aclnnFusedCrossEntropyLossWithMaxSumGetWorkspaceSize.

    • executor (aclOpExecutor*, input): operator executor, containing the operator computation process.

    • stream (aclrtStream, input): stream for executing the task.

  • Returns:

    aclnnStatus: status code. For details, see .

[object Object]
  • Deterministic computation:
    • aclnnFusedCrossEntropyLossWithMaxSum defaults to a deterministic implementation.
[object Object]

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

[object Object]