Formula:
The backpropagation of SmoothL1Loss can be computed through derivation. For the first case of SmoothL1Loss, that is, |x – y| < 1, the derivative is:
For the second case of SmoothL1Loss, that is, |x – y| ≥ 1, the derivative is:
sign(x) represents a sign function of x, that is:
Each operator has calls. First, aclnnSmoothL1LossBackwardGetWorkspaceSize is called to obtain the workspace size required for computation and the executor that contains the operator computation process. Then, aclnnSmoothL1LossBackward is called to perform computation.
[object Object][object Object]
Parameters:
gradOut (aclTensor*, compute input): gradient backward input,
[object Object]in the formula, and aclTensor on the device. Its shape and the shapes of self and target must meet the . Its data type and the data types of self and target must meet the . are supported. The can be ND.- [object Object]Atlas training series products[object Object] and [object Object]Atlas inference series products[object Object]: The data type can be FLOAT16 or FLOAT32.
- [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 FLOAT32.
self (aclTensor*, input):
[object Object]in the formula, aclTensor on the device. Its shape and the shapes of gradOut and target must meet the . Its data type and the data types of gradOut and target must meet the . are supported. The can be ND.- [object Object]Atlas training series products[object Object] and [object Object]Atlas inference series products[object Object]: The data type can be FLOAT16 or FLOAT32.
- [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 FLOAT32.
target (aclTensor*, input):
[object Object]in the formula, aclTensor on the device. Its shape and the shapes of gradOut and self must meet the . Its data type and the data types of gradOut and self must meet the . are supported. The can be ND.- [object Object]Atlas training series products[object Object] and [object Object]Atlas inference series products[object Object]: The data type can be FLOAT16 or FLOAT32.
- [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 FLOAT32.
reduction (int64_t, compute input): compute attribute, reduction to be applied to the output, integer on the host. The value can be 0 ('none') | 1 ('mean') | 2 ('sum'). none indicates that no reduction will be 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.
beta (float, compute input): compute attribute, which specifies the value changed between L1 and L2 losses. The data type is FLOAT. The value must be non-negative.
gradInput (aclTensor*, compute output): The shape is the same as that of gradOut, self, or target after broadcasting is performed. are supported. The can be ND.
- [object Object]Atlas training series products[object Object] and [object Object]Atlas inference series products[object Object]: The data type can be FLOAT16 or FLOAT32.
- [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 FLOAT32.
workspaceSize (uint64_t*, output): size of the workspace required 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 aclnnSmoothL1LossBackwardGetWorkspaceSize.
executor (aclOpExecutor*, input): operator executor, containing the operator computation process.
stream (aclrtStream, input): stream for executing the task.
Returns:
- Deterministic compute:
- aclnnSmoothL1LossBackward defaults to a deterministic implementation.
The following example is for reference only. For details, see .