- API description: Performs backpropagation of to compute the gradients of tensors input and grid.
- Formulas:
Computing process:
- The coordinates mapped to input are calculated based on the (x, y) values stored in grid. The coordinates are related to alignCorners and paddingMode.
- Based on the input interpolationMode, the bilinear or nearest interpolation mode is used to calculate the weight of the point around the coordinate allocated to the gradient.
- The final dx and dgrid results are calculated based on the gradient value stored in grad multiplied by the weight of the corresponding point.
The values are as follows: The dimensions of grad, input, grid, dx, and dgrid are as follows:
The values of N in grad, input, grid, dx, and dgrid are the same. The values of C in grad, input, and dx are the same. The values of and in input and dx are the same. The values of and in grad, grid, and dgrid are the same. The last dimension of grid is 2, indicating that the pixel position information of the input is (x, y). The values of x and y are normalized to the range of [-1, 1]. (-1, 1) indicates the coordinates of the upper left corner, and (1, -1) indicates the coordinates of the lower right corner.
Out-of-bound coordinates are processed based on the padding mode.
- paddingMode="zeros": Use 0 for out-of-bound locations.
- paddingMode="border": Use border values for out-of-bound locations.
- paddingMode="reflection": Use symmetric values of the border values for out-of-bound locations.
During input sampling, the processing varies according to interpolationMode.
- interpolationMode="bilinear": Use the weighted average value of the 4 coordinates around (x, y) in the input.
- interpolationMode="nearest": Use the nearest coordinates to (x, y) in the input.
Each operator has calls. First, aclnnGridSampler2DBackwardGetWorkspaceSize is called to obtain the workspace size required for computation and the executor that contains the operator computation process. Then, aclnnGridSampler2DBackward is called to perform computation.
Parameters
[object Object][object Object]Atlas training products[object Object]:
The data types of gradOutput, input, grid, inputGrad, and gridGrad do not support BFLOAT16 or DOUBLE.
Returns:
[object Object]: status code. For details, see .The first-phase API implements input parameter validation. The following error codes may be returned.
[object Object]
- Deterministic computation:
- aclnnGridSampler2DBackward defaults to a non-deterministic implementation. You can call aclrtCtxSetSysParamOpt to enable deterministic computing. A deterministic implementation must meet the following conditions:
- The input and output data types are not DOUBLE.
- The C axes of the input and output are less than or equal to 2,048.
- aclnnGridSampler2DBackward defaults to a non-deterministic implementation. You can call aclrtCtxSetSysParamOpt to enable deterministic computing. A deterministic implementation must meet the following conditions:
The following example is for reference only. For details, see .