Function: performs the backpropagation of 2D average pooling and calculates the input gradient of the forward propagation of 2D average pooling.
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, [object Object] is called to obtain the workspace size required for computation and the executor that contains the operator computation process. Then, [object Object] is called to perform computation.
Parameters:
[object Object]cubeMathType: The following enumerated values are supported:
- 0: KEEP_DTYPE. The input data type is retained for computation.
- [object Object]Atlas training products[object Object] and [object Object]Atlas inference 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 products[object Object] and [object Object]Atlas inference 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 products/Atlas A3 inference 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.
- Ascend 950PR/Ascend 950DT: In global pooling mode, when the input data type is FLOAT32, the data 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 products/Atlas A3 inference products[object Object]: This option is not supported when the input data type is BFLOAT16.
- Ascend 950PR/Ascend 950DT: In global pooling mode, 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 products[object Object] and [object Object]Atlas inference 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 products/Atlas A3 inference 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.
- Ascend 950PR/Ascend 950DT: In global pooling mode, when the input data type is FLOAT32, it will be 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.
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 compute:
- aclnnAvgPool2dBackward defaults to a non-deterministic implementation. You can call aclrtCtxSetSysParamOpt to enable deterministic compute.
[object Object]Atlas training products[object Object] and [object Object]Atlas inference 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 .