[object Object]

[object Object][object Object]undefined
[object Object]
  • Description: backward operator of ChamferDistance, which computes the gradients of the forward inputs based on their contribution to the forward output and the initial gradients.

  • 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:

      • Derivative of dist1idist1_i with respect to x1ix_{1_i}=2grad_dist1(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.

      • Derivative of dist1idist1_i with respect to y1iy_{1_i}=2grad_dist1(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.

      • Derivative of dist1idist1_i with respect to x2x_2=2grad_dist1(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. Parallel computation is not supported; only single-point computation is allowed, as gradient updates rely on indices corresponding to minimum distances.

      • Derivative of dist1idist1_i with respect to y2y_2 = –2grad_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. Parallel computation is not supported; only single-point computation is allowed, as gradient updates rely on indices corresponding to minimum values.

    The derivatives of dist2idist2_i with respect to x2ix_{2_i}, x1x_1, y2iy_{2_i}, and y1y_1 follow a similar process and are omitted here.

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

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

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

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

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

[object Object]

Each operator has calls. First, aclnnChamferDistanceBackwardGetWorkspaceSize is called to obtain the workspace size required for computation and the executor that contains the operator computation flow. Then, aclnnChamferDistanceBackward is called to perform computation.

  • [object Object]
  • [object Object]
[object Object]
  • Parameters

    • xyz1 (aclTensor*, input): coordinates of point set 1 from the forward operator input, stored as a device-side aclTensor. Data type: FLOAT or FLOAT16; must match that of xyz2, grad_dist1, grad_dist2, grad_xyz1, and grad_xyz2. Shape: (B,N,2). : ND.
    • xyz2 (aclTensor*, input): coordinates of point set 2 from the forward operator input, stored as a device-side aclTensor. Data type: FLOAT or FLOAT16; must match that of xyz2, grad_dist1, grad_dist2, grad_xyz1, and grad_xyz2. Shape: (B,N,2). : ND.
    • idx1 (aclTensor*, input): indices of the nearest points in xyz2 for each point in xyz1 from the forward operator output, stored as a device-side aclTensor. Data type: INT32; must match that of idx2. Shape: (B,N). : ND.
    • idx2 (aclTensor*, input): indices of the nearest points in xyz1 for each point in xyz2 from the forward operator output, stored as a device-side aclTensor. Data type: INT32; must match that of idx1. Shape: (B,N). : ND.
    • gradDist1 (aclTensor*, input): backward gradient of the forward output dist1, serving as the initial gradient for the backward operator, stored as a device-side aclTensor. Data type: FLOAT or FLOAT16; must match that of xyz2, xyz1, grad_dist2, grad_xyz1, and grad_xyz2. Shape: (B,N). : ND.
    • gradDist2 (aclTensor*, output): backward gradient of the forward output dist2, serving as the initial gradient for the backward operator, stored as a device-side aclTensor. Data type: FLOAT or FLOAT16; must match that of xyz2, xyz1, grad_dist2, grad_xyz1, and grad_xyz2. Shape: (B,N). : ND.
    • gradXyz1 (aclTensor*, output): gradient of the forward input xyz1 after gradient update, stored as a device-side aclTensor. Data type: FLOAT or FLOAT16; must match that of xyz1, xyz2, grad_dist1, grad_dist2, and grad_xyz2. Shape: (B,N,2). : ND.
    • gradXyz2 (aclTensor*, output): backward gradient of the forward output dist2, serving as the initial gradient for the backward operator, stored as a device-side aclTensor. Data type: FLOAT or FLOAT16; must match that of xyz1, xyz2, grad_dist1, grad_dist2, and grad_xyz1. Shape: (B,N,2). : ND.
    • workspaceSize (uint64_t*, output): size of the workspace to be allocated on the device.
    • executor (aclOpExecutor**, output): operator executor that contains the operator computation flow.
  • Returns

    aclnnStatus: status code. For details, see .

[object Object]
[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 via the first-phase API aclnnChamferDistanceBackwardGetWorkspaceSize.
    • executor (aclOpExecutor*, input): operator executor that contains the operator computation flow.
    • stream (aclrtStream, input): stream for executing the task.
  • Returns

    aclnnStatus: 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]