[object Object]

[object Object][object Object]undefined
[object Object]
  • 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 XX, the output tensor is YY, the pooling window size is kkk*k, and the stride is ss. The gradient LX\frac{\partial L}{\partial X} of XX is calculated as follows:

    LXi,j=1k2n=0k1LYis+mk,js+nk\frac{\partial L}{\partial X_{i,j}}=\frac{1}{k^2}\sum_{n=0}^{k-1}\frac{\partial L}{\partial Y_{\lfloor\frac{i*s+m}{k}\rfloor,\lfloor\frac{j*s+n}{k}\rfloor}}

    The parameters are described as follows:

    • LL is the loss function, and \lfloor\cdot\rfloor indicates rounding up.
    • Xi,jX_{i,j} indicates the iith row and jjth column of the input feature map.
    • Yis+mk,js+nkY_{\lfloor\frac{i*s+m}{k}\rfloor,\lfloor\frac{j*s+n}{k}\rfloor} indicates the pixel value in row is+mk\lfloor\frac{i*s+m}{k}\rfloor and column js+nk\lfloor\frac{j*s+n}{k}\rfloor of the output feature map.
    • kk indicates the size of the pooling window.
    • ss indicates the stride.
    • LXi,j\frac{\partial L}{\partial X_{i,j}} 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.
    • LYis+mk,js+nk\frac{\partial L}{\partial Y_{\lfloor\frac{i*s+m}{k}\rfloor,\lfloor\frac{j*s+n}{k}\rfloor}} indicates the partial derivative of the loss function LL with respect to the pixel value in row is+mk\lfloor\frac{is+m}{k}\rfloor and column js+nk\lfloor\frac{js+n}{k}\rfloor of the feature map.
[object Object]

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.

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

[object Object]

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

[object Object]