Description: Computes the negative log-likelihood loss.
Formula:
If
[object Object]is[object Object]:indicates self, indicates target, indicates weight, and indicates the batch size. If
[object Object]is not[object Object]:
Each operator has calls. First, aclnnNLLLoss2dGetWorkspaceSize is called to obtain the workspace size required for computation and the executor that contains the operator computation process. Then, aclnnNLLLoss2d is called to perform computation.
[object Object][object Object]
Parameters:
self (aclTensor*, compute input): aclTensor on the device, tensor to be computed, input x in the formula. The shape is four-dimensional, and the second dimension is C, indicating the number of classes. are supported. The can be ND.
- [object Object]Atlas inference series products[object Object] and [object Object]Atlas training series products[object Object]: The data type can be FLOAT or FLOAT16.
- [object Object]Atlas A2 training products/Atlas A2 inference products[object Object] and [object Object]Atlas A3 training series products/Atlas A3 inference series products[object Object]: The data type can be FLOAT, FLOAT16, or BFLOAT16.
target (aclTensor*, compute input): aclTensor on the device, real label, y in the formula. The shape has three dimensions. The first dimension of target is equal to the first dimension of self, the second dimension of target is equal to the third dimension of self, and the third dimension of target is equal to the fourth dimension of self. The value range of each element is [0, C – 1]. The data type can be INT64, UINT8, or INT32. are supported. The can be ND.
weight (aclTensor*, compute input): aclTensor on the device, scaling weight of each class, w in the formula. The shape is (C,). The data type must be the same as that of self. are supported. The can be ND.
- [object Object]Atlas inference series products[object Object] and [object Object]Atlas training series products[object Object]: The data type can be FLOAT or FLOAT16.
- [object Object]Atlas A2 training products/Atlas A2 inference products[object Object] and [object Object]Atlas A3 training series products/Atlas A3 inference series products[object Object]: The data type can be FLOAT, FLOAT16, or BFLOAT16.
reduction (int64_t, compute input): int64_t on the host, reduction to be applied to the output, reduction in the formula. The value can be 0 ('none'), 1 ('mean'), or 2 ('sum'). none indicates that no reduction is applied; mean indicates that the sum of the output will be divided by the number of elements in the output; sum indicates that the output will be summed.
ignoreIndex (int64_t, compute input): int64_t on the host, target value that is ignored and does not affect the input gradient, ignoreIndex in the formula.
out (aclTensor*, compute output): aclTensor on the device. The data type must be the same as that of self. When reduction is 0 (none), the shape is the same as that of target. Otherwise, the shape is (1,). The can be ND.
- [object Object]Atlas inference series products[object Object] and [object Object]Atlas training series products[object Object]: The data type can be FLOAT or FLOAT16.
- [object Object]Atlas A2 training products/Atlas A2 inference products[object Object] and [object Object]Atlas A3 training series products/Atlas A3 inference series products[object Object]: The data type can be FLOAT, FLOAT16, or BFLOAT16.
totalWeightOut (aclTensor*, compute output): aclTensor on the device, which indicates the sum of weights. The data type must be the same as that of self. The output value is valid when reduction is not 0 (none). The shape is (1,). The can be ND.
- [object Object]Atlas inference series products[object Object] and [object Object]Atlas training series products[object Object]: The data type can be FLOAT or FLOAT16.
- [object Object]Atlas A2 training products/Atlas A2 inference products[object Object] and [object Object]Atlas A3 training series products/Atlas A3 inference series products[object Object]: The data type can be FLOAT, FLOAT16, or BFLOAT16.
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:
Parameters:
workspace (void*, input): address of the workspace to be allocated on the device.
workspaceSize (uint64_t, input): size of the workspace to be allocated on the device, which is obtained by the first-phase API aclnnNLLLoss2dGetWorkspaceSize.
executor (aclOpExecutor*, input): operator executor, containing the operator computation process.
stream (aclrtStream, input): stream for executing the task.
Returns:
- Deterministic compute:
- aclnnNLLLoss2d defaults to a non-deterministic implementation. You can call aclrtCtxSetSysParamOpt to enable deterministic compute.
The following example is for reference only. For details, see .