Description: Performs backpropagation of 2D average pooling, which calculates the input gradient of 2D average pooling forward propagation.
The calculation formula is as follows: Assume that the input tensor of forward propagation of 2D average pooling is , the output tensor is , the pooling window size is , and the stride is . The gradient of is calculated as follows:
The parameters are described as follows:
- is the loss function, and indicates rounding up.
- indicates the th row and th column of the input feature map.
- indicates the pixel value in row and column of the output feature map.
- indicates the size of the pooling window.
- indicates the stride.
- indicates the partial derivative of the loss function L with respect to the pixel value in the ith row and jth column of the input feature map.
- indicates the partial derivative of the loss function with respect to the pixel value in row and column of the feature map.
Each operator has calls. First, aclnnAvgPool2dBackwardGetWorkspaceSize is called to obtain the workspace size required for computation and the executor that contains the operator computation process. Then, aclnnAvgPool2dBackward is called to perform computation.
[object Object][object Object]
Parameters:
- gradOutput (aclTensor *, compute input): input gradient, which is in the formula. It is an aclTensor on the device and does not support empty tensors. are supported. The can be NCHW or NCL.
- [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.
- [object Object]Atlas inference series products[object Object] and [object Object]Atlas training series products[object Object]: The data type can be FLOAT16 or FLOAT32.
- self (aclTensor *, compute input): input data, which is an aclTensor on the device and indicates the input in the forward process. are supported. The can be NCHW or NCL.
- [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.
- [object Object]Atlas inference series products[object Object] and [object Object]Atlas training series products[object Object]: The data type can be FLOAT16 or FLOAT32.
- kernelSize (aclIntArray *, compute input): pooling window size ( in the formula), which is an aclIntArray on the host. It is an INT64 array, with a length of 1 () or 2 ().
- stride (aclIntArray *, compute input): pooling stride ( in the formula), which is an aclIntArray on the host. It is an INT64 array, with a length of 0 (), 1 (), or 2 ().
- padding (aclIntArray *, compute input): number of zero-padding layers in the H and W directions of the input ( in the formula), which is an aclIntArray on the host. It is an INT64 array, with a length of 1 () or 2 ().
- ceilMode (bool, compute input): whether to round up the output shape deduced during forward average pooling. The data type can be BOOL.
- countIncludePad (bool, compute input): whether to include the padded zeros when computing forward average pooling. The data type can be BOOL.
- divisorOverride (int64_t, compute input): divisor for averaging.
- [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 value range is not limited. The value 0 indicates that whether padding is involved in average computation is not affected. The data type can be INT64.
- [object Object]Atlas inference series products[object Object] and [object Object]Atlas training series products[object Object]: The value range is [–255, +255]. The value 0 indicates that whether padding is involved in average computation is not affected. The data type can be INT64.
- cubeMathType (INT8, compute input): compute logic of the Cube unit, which is an integer on the host. The data type can be INT8. Note: If the input data types can be deduced from each other, this parameter processes the deduced data type by default. The supported enumerated values are as follows:
- 0: KEEP_DTYPE. The input data type is retained for computation.
- [object Object]Atlas training series products[object Object] and [object Object]Atlas inference series products[object Object]: This option is not supported when the input data type is FLOAT32.
- 1: ALLOW_FP32_DOWN_PRECISION. The input data can be computed with reduced precision.
- [object Object]Atlas training series products[object Object] and [object Object]Atlas inference series products[object Object]: If the input data type is FLOAT32, it will be converted to FLOAT16 for computation. When the input is of other data types, it is not processed.
- [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]: If the input data type is FLOAT32, it is converted to HFLOAT32 for computation. When the input is of other data types, it is not processed.
- 2: USE_FP16. The input data can be downgraded to FLOAT16 for computation.
- [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]: This option is not supported when the input data type is BFLOAT16.
- 3: USE_HF32. The input data can be downgraded to HFLOAT32 for computation.
- [object Object]Atlas training series products[object Object] and [object Object]Atlas inference series products[object Object]: This option is not supported.
- [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]: If the input data type is FLOAT32, it is converted to HFLOAT32 for computation. When the input is of other data types, this option is not supported.
- 0: KEEP_DTYPE. The input data type is retained for computation.
- gradInput (aclTensor *, compute output): aclTensor on the device. are supported. The can be NCHW or NCL. The data type and must be the same as those of self.
- [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.
- [object Object]Atlas inference series products[object Object] and [object Object]Atlas training series products[object Object]: The data type can be FLOAT16 or FLOAT32.
- workSpaceSize (uint64_t *, output): size of the workspace to be allocated on the device.
- executor (aclOpExecutor**, output): operator executor, containing the operator computation process.
- gradOutput (aclTensor *, compute input): input gradient, which is in the formula. It is an aclTensor on the device and does not support empty tensors. are supported. The can be NCHW or NCL.
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 calling the first-phase API aclnnAvgPool2dBackwardGetWorkspaceSize.
- executor (aclOpExecutor*, input): operator executor, containing the operator computation process.
- stream (aclrtStream, input): stream for executing the task.
Returns:
Deterministic compute:
- aclnnAvgPool2dBackward defaults to a non-deterministic implementation. You can call aclrtCtxSetSysParamOpt to enable deterministic compute.
[object Object]Atlas training series products[object Object] and [object Object]Atlas inference series products[object Object]: The Cube unit does not support FLOAT32 computation. The input data type FLOAT32 can be converted to FLOAT16 in the API for computation by setting cubeMathType to 1 (ALLOW_FP32_DOWN_PRECISION).
The following example is for reference only. For details, see .