[object Object]

[object Object][object Object]undefined
[object Object]
  • 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:

      dist1i=Min((x1ix2)2+(y1iy2)2),x2,y2xyz2dist1_i=Min((x_{1_i}-x_2)^2+(y_{1_i}-y_2)^2), x_2, y_2∈xyz2 dist2i=Min((x2ix1)2+(y2iy1)2),x1,y1xyz1dist2_i=Min((x_{2_i}-x_1)^2+(y_{2_i}-y_1)^2), x_1, y_1∈xyz1

    • Backward operator (derivative) formula:

      • The derivative of dist1idist1_i to x1ix_{1_i} is 2graddist1(x1ix2)2*grad_dist1*(x_{1_i}-x_2).

        Where x1ixyz1x_{1_i}∈xyz1, and x2x_2 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 dist1idist1_i to y1iy_{1_i} is 2graddist1(y1iy2)2*grad_dist1*(y_{1_i}-y_2).

        Where y1ixyz1y_{1_i}∈xyz1, and y2y_2 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 dist1idist1_i with respect to x2x_2 is 2grad_dist1(x1x2i)-2*grad\_dist1*(x_1-x_{2_i}).

        where x2ixyz2x_{2_i}∈xyz2, and x1x_1 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 dist1idist1_i with respect to y2y_2 is 2grad_dist1(y1y2i)-2*grad\_dist1*(y_1-y_{2_i}).

        where y2ixyz2y_{2_i}∈xyz2, and y1y_1 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 dist2idist2_i with respect to x2ix_{2_i}, x1x_1, y2iy_{2_i}, and y1y_1 are similar to the preceding process. Details are not described here.

    Final computation formulas (i∈[0,n)):

    gradxyz1[2i]=2grad_dist1(x1ix2)2grad_dist1(x1x2i)grad_xyz1[2*i] = 2*grad\_dist1*(x_{1_i}-x_2) - 2*grad\_dist1*(x_1-x_{2_i})

    gradxyz1[2i+1]=2grad_dist1(y1iy2)2grad_dist1(y1y2i)grad_xyz1[2*i+1] = 2*grad\_dist1*(y_{1_i}-y_2) - 2*grad\_dist1*(y_1-y_{2_i})

    gradxyz2[2i]=2grad_dist2(x1ix2)2grad_dist2(x1x2i)grad_xyz2[2*i] = 2*grad\_dist2*(x_{1_i}-x_2) - 2*grad\_dist2*(x_1-x_{2_i})

    gradxyz2[2i+1]=2grad_dist2(y1iy2)2grad_dist2(y1y2i)grad_xyz2[2*i+1] = 2*grad\_dist2*(y_{1_i}-y_2) - 2*grad\_dist2*(y_1-y_{2_i})

[object Object]

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.

[object Object]
[object Object]
[object Object]
  • 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]
[object Object]
  • Parameters

    [object Object]
  • Returns

    [object Object]: status code. For details, see .

[object Object]
  • Deterministic computation:
    • aclnnChamferDistanceBackward is non-deterministic by default. Deterministic mode can be enabled via aclrtCtxSetSysParamOpt.
[object Object]

The following example is for reference only. For details, see .

[object Object]