[object Object]

[object Object][object Object]undefined
[object Object]
  • Description: Performs two-dimensional average pooling over the input tensor with the window of kHkWkH * kW and stride of sHsWsH * sW. Specifically, kk is kernelSize, indicating the size of the pooling window. ss is stride, indicating the stride of the pooling operation.
  • Formula: The relationship among input (N,C,H,WN,C,H,W), output out (N,C,Hout,WoutN,C,H_{out},W_{out}), pooling step (stridesstrides), and pooling window size (kH,kWkH,kW) is as follows:
Hout=Hin+2paddings[0]kHstrides[0]+1H_{out}=\lfloor \frac{H_{in}+2*paddings[0]-kH}{strides[0]}+1 \rfloor Wout=Win+2paddings[1]kWstrides[1]+1W_{out}=\lfloor \frac{W_{in}+2*paddings[1]-kW}{strides[1]}+1 \rfloor out(Ni,Ci,h,w)=1kHkWm=0kH1n=0kW1input(Ni,Ci,strides[0]h+m,strides[1]w+n)out(N_i,C_i,h,w)=\frac{1}{kH*kW}\sum_{m=0}^{kH-1}\sum_{n=0}^{kW-1}input(N_i,C_i,strides[0]*h+m,strides[1]*w+n) [object Object]

Each operator has calls. First, aclnnAvgPool2dGetWorkspaceSize is called to obtain the workspace size required for computation and the executor that contains the operator computation process. Then, aclnnAvgPool2d is called to perform computation.

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

    • self (aclTensor*, compute input): tensor to be converted (inputinput in the formula), which is a tensor on the device. Empty tensors are not supported. are supported, and 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 (kk in the formula), which is an aclIntArray on the host. The length is 1 (kH=kWkH=kW) or 2 (kH,kWkH, kW). The data type is INT64. The value must be greater than 0.

    • strides (aclIntArray*, compute input): pooling stride (stridesstrides in the formula), which is an aclIntArray on the host. The length is 1 (sH=sWsH=sW) or 2 (sH,sWsH, sW). The data type is INT64. The value must be greater than 0.

    • paddings (aclIntArray*, compute input): number of zero-padding layers in the H and W directions of the input (paddingspaddings in the formula), which is an aclIntArray on the host. The length is 1 (padH=padWpadH=padW) or 2 (padH,padWpadH, padW). The data type is INT64. The value cannot be less than 0.

    • ceilMode (bool, compute input): whether the shape of the deduced output out is rounded up. The data type can be BOOL.

    • countIncludePad (bool, compute input): whether to include padded zeros when computing average pooling. The data type can be BOOL.

    • divisorOverride (int64_t, compute input): divisor for computing average pooling. The data type is INT64. If divisorOverride is set to 0, the function is disabled.

    • 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]: This option is not supported when the input data type is FLOAT32. 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. This option is not supported.
    • out (aclTensor*, compute output): output tensor, which is outout in the formula. 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.

  • 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 by calling the first-phase API aclnnAvgPool2dGetWorkspaceSize.
    • executor (aclOpExecutor *, input): operator executor, containing the operator computation process.
    • stream (aclrtStream, input): stream for executing the task.
  • Returns:

    aclnnStatus: status code. For details, see .

[object Object]
  • Deterministic compute:

    • aclnnAvgPool2d defaults to a deterministic implementation.
  • [object Object]Atlas training 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).

[object Object]

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

[object Object]