- Description: Computes the negative log likelihood loss.
- Formula:
self is the input, with shape (N, C) or (C), where N indicates the batch size and C indicates the number of classes. target indicates the real label, with shape (N, C) or (C). The value range of each element is [-1, C - 1]. To ensure that the shape is the same as that of the input, -1 is padded. That is, the label before the first -1 indicates the real label yTrue to which the sample belongs. For example, if y = [0,3,-1,1], the real label yTrue is [0,3]. The formula for calculating each sample is as follows:
If
[object Object]is[object Object]: If[object Object]is not[object Object]:
Each operator has calls. First, aclnnMultilabelMarginLossGetWorkspaceSize is called to obtain the workspace size required for computation and the executor that contains the operator computation process. Then, aclnnMultilabelMarginLoss is called to perform computation.
[object Object][object Object]
Parameters
- self (aclTensor*, compute input): input
[object Object]in the formula, which is an aclTensor on the device. The shape is (N, C) or (C). N indicates the batch size, and C indicates the number of classes. The data types of self, out, and isTarget are the same. are supported. The can be ND.- [object Object]Atlas training series products[object Object]: The data type can be FLOAT16 or FLOAT. If the number of elements in
[object Object]is greater than 15000*20000, a runtime timeout error (507034 Vector Core execution timed out) may occur. - [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 BFLOAT16, FLOAT16, or FLOAT. If the number of elements in
[object Object]is greater than 15000*20000, a runtime timeout error (507034 Vector Core execution timed out) may occur.
- [object Object]Atlas training series products[object Object]: The data type can be FLOAT16 or FLOAT. If the number of elements in
- target (aclTensor*, compute input):
[object Object]in the formula, aclTensor on the device, indicating the real label, with shape (N, C) or (C). The range of each element is [-1, C - 1], and -1 is padded. The label before the first -1 indicates the real label of the sample. The data type can be INT64 or INT32. are supported. The can be ND. - reduction (int64_t, compute input):
[object Object]in the formula, an integer on the host, specifying the reduction to be applied to the output. The supported values are 0 (none) | 1 (mean) | 2 (sum). none indicates that no reduction is applied; mean indicates that the sum of the output will be divided by the number of samples in the output; sum indicates that the output will be summed. - out (aclTensor*, compute output):
[object Object]in the formula, aclTensor on the device. The data types of self, out, and isTarget are the same, and the shape is (N) or (). The can be ND.- [object Object]Atlas training series products[object Object]: The data type can be FLOAT16 or FLOAT.
- [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 BFLOAT16, FLOAT16, or FLOAT.
- isTarget (aclTensor*, compute output):
[object Object]in the formula, aclTensor on the device. The data types of self, out, and isTarget are the same, and the shape is (N, C) or (C). are supported. The can be ND.- [object Object]Atlas training series products[object Object]: The data type can be FLOAT16 or FLOAT.
- [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 BFLOAT16, FLOAT16, or 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.
- self (aclTensor*, compute input): input
Returns:
[object Object]
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 aclnnMultilabelMarginLossGetWorkspaceSize.
- executor (aclOpExecutor*, input): operator executor, containing the operator computation process.
- stream (aclrtStream, input): stream for executing the task.
Returns:
- Deterministic compute:
- aclnnMultilabelMarginLoss defaults to a non-deterministic implementation. You can call aclrtCtxSetSysParamOpt to enable deterministic compute.
The following example is for reference only. For details, see .
[object Object]