- Description: Calculates the KL divergence.
- Formula:
Defines loss_pointwise and saves the intermediate result.
Formula for computing
[object Object]:
Each operator has calls. First, [object Object] is called to obtain the input parameters and compute the required workspace size based on the process. Then, [object Object] is called to perform computation.
[object Object][object Object]
Parameters:
[object Object](aclTensor*, compute input):[object Object]in the formula.[object Object]on the device. The data type must meet the type deduction rules (for details, see ) with target, and the shape must meet the with target. are supported. The can be ND.- [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].
- [object Object]Atlas inference products[object Object] and [object Object]Atlas training products[object Object]: FLOAT, FLOAT16.
[object Object](aclTensor*, compute input):[object Object]in the formula. The data type must meet the type deduction rules (see ) with self, and the shape must meet the with self. are supported. The can be ND. [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]. [object Object]Atlas inference products[object Object] and [object Object]Atlas training products[object Object]: FLOAT, FLOAT16.[object Object](int64_t, compute input):[object Object]in the formula, which specifies the operation after loss_pointwise is computed.- 0: none, indicating that the reduction operation is not performed.
- 1: mean, indicating that the mean value of loss_pointwise is computed.
- 2: sum, indicating the sum of loss_pointwise.
- 3: batchmean, indicating that the average loss of a batch is computed, which is consistent with the mathematical definition of Kullback-Leibler divergence.
[object Object](bool, compute input): specifies whether the input target data has been computed using the logarithm.[object Object](aclTensor*, compute output):[object Object]in the formula. The data types of out and self must meet the type deduction rules (see ). When[object Object]is 0, the shape must meet the with[object Object]and[object Object]. When[object Object]is not 0, the shape is fixed at (1,). The can be ND. [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]. [object Object]Atlas inference products[object Object] and [object Object]Atlas training products[object Object]: FLOAT, FLOAT16.[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]
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 aclnnKlDivGetWorkspaceSize.[object Object](aclOpExecutor*, input): operator executor, containing the operator computation process.[object Object](aclrtStream, input): stream for executing the task.
Returns:
- Deterministic computation:
[object Object]defaults to a deterministic implementation.
The following example is for reference only. For details, see .
[object Object]