Function: This API is the backward operator of ChamferDistance. It calculates the gradient of the input based on the contribution of the forward input to the output and the initial gradient.
Formula:
Assume there are two point sets: xyz1=[B,N,2], xyz2=[B,M,2]
Forward ChamferDistance formula:
Backward operator (derivative) formula:
The derivative of to is .
Where , and denotes the x-coordinate of the nearest point in xyz2 indexed by the forward output id1. The single-point derivative formula above supports multi-point parallel computation due to continuous gradient update positions.
The derivative of to is .
Where , and denotes the y-coordinate of the nearest point in xyz2 indexed by the forward output id1. The single-point derivative formula above supports multi-point parallel computation due to continuous gradient update positions.
The derivative of with respect to is .
where , and is the horizontal coordinate of the point with the minimum distance obtained from xyz2 based on the index value of id1 output in the forward direction. The preceding formula is used for calculating the gradient of a single point. Because the gradient of a single point needs to be updated based on the index value corresponding to the minimum distance, this operation can only be performed on a single point and cannot be parallelized.
The derivative of with respect to is .
where , and is the vertical coordinate of the point with the minimum distance obtained from xyz2 based on the index value of id1 output in the forward direction. The preceding formula is used for calculating the gradient of a single point. Because the gradient of a single point needs to be updated based on the index value corresponding to the minimum distance, this operation can only be performed on a single point and cannot be parallelized.
The derivatives of with respect to , , , and are similar to the preceding process. Details are not described here.
Final computation formulas (i∈[0,n)):
Each operator is divided into two functions (../common/Two-Phase Interface.md). You must call aclnnChamferDistanceBackwardGetWorkspaceSize to obtain the input parameters and calculate the required workspace size based on the workflow, and then call aclnnChamferDistanceBackward to perform the computation.
Parameters
[object Object]Returns
[object Object]: status code. For details, see .The first-phase API implements input parameter verification. The following errors may be thrown.
[object Object]
- Deterministic computation:
- aclnnChamferDistanceBackward is non-deterministic by default. Deterministic mode can be enabled via aclrtCtxSetSysParamOpt.
The following example is for reference only. For details, see .