[object Object]

[object Object][object Object]undefined
[object Object]
  • Description: Provides two-dimensional max pooling for the input channels of the input signal, and outputs the pooled value out and indices (calculated using the mask semantics).

  • Formula:

    • Calculation formula of each element of the output tensor:

      out(Nj,Cj,h,w)=maxm[0,kH1],n[0,kW1]input(Ni,Cj,stride[0]×h+m,stride[1]×w+n)out(N_j, C_j, h, w) = \max\limits_{{m\in[0,k_{H}-1],n\in[0,k_{W}-1]}}input(N_i,C_j,stride[0]\times h + m, stride[1]\times w + n)
    • For the shape inference of out tensor:

      [N,C,Hout,Wout]=[N,C,Hin+2×padding[0]dilation[0]×(kernelSize[0]1)1stride[0]+1,Win+2×padding[1]dilation[1]×(kernelSize[1]1)1stride[1]+1][N, C, H_{out}, W_{out}]=[N,C,\lfloor{\frac{H_{in}+2 \times {padding[0] - dilation[0] \times(kernelSize[0] - 1) - 1}}{stride[0]}}\rfloor + 1,\lfloor{\frac{W_{in}+2 \times {padding[1] - dilation[1] \times(kernelSize[1] - 1) - 1}}{stride[1]}}\rfloor + 1]
    • For the shape inference of indices tensor:

      [N,C,Hindices,Windices]=[N,C,kh×kw,(Hout×Wout16+1)×2×16][N, C, H_{indices}, W_{indices}]=[N,C,k_h \times k_w, (\lceil{\frac{H_{out} \times W_{out}}{16}}\rceil+1) \times 2 \times 16]
[object Object]

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

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

    • self (aclTensor*, compute input): input tensor, which is input in the formula. It is an aclTensor on the device. The shape can only be three-dimensional or four-dimensional. are supported. When the is three-dimensional, ND is supported. When the data format is four-dimensional, NCHW is supported.
      • [object Object]Atlas inference series products[object Object]: The data type can be FLOAT.
      • [object Object]Atlas training series products[object Object]: The data type can be FLOAT or FLOAT16.
      • [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 FLOAT, FLOAT16, and BFLOAT16.
    • kernelSize (aclIntArray*, compute input): size of the maximum pooling window, which is k in the formula. It is an aclIntArray on the host. The data type can be INT64. The array length must be 1 or 2, and all array elements must be greater than 0.
    • stride (aclIntArray*, compute input): stride of the window, which is stride in the formula. It is an aclIntArray on the host. The data type can be INT64. When the stride length is 0, the value of stride is equal to that of kernelSize.
    • padding (aclIntArray*, compute input): the number of layers of padding to be applied on each side, padding_size in the formula, aclIntArray on the host, with negative infinity values used for padding. The data type can be INT64. The array length must be 1 or 2, and the array elements must be greater than or equal to 0 or less than or equal to kernelSize divided by 2.
    • dilation (aclIntArray*, compute input): controls the stride of elements in the window, dilation_size in the formula, aclIntArray on the host. The data type can be INT64. The value can only be 1.
    • ceilMode (bool, compute input): controls the value mode when the out shape is inferred. It is of the Bool type on the host. Only true or false is supported. If the value is true, round up to infer the shapes of Hout and Wout. If the value is false, round down.
    • out (aclTensor*, compute output): output tensor, out in the formula, aclTensor on the device. It is the pooled result. The shape needs to be calculated according to the shape inference formula of out in the function description. The supports ND in three dimensions and NCHW in four dimensions, which is the same as that of self.
      • [object Object]Atlas inference series products[object Object]: The data type can be FLOAT.
      • [object Object]Atlas training series products[object Object]: The data type can be FLOAT or FLOAT16.
      • [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 FLOAT, FLOAT16, and BFLOAT16.
    • indices (aclTensor*, compute output): output tensor, aclTensor on the device. This tensor consists of the index positions of maximum values (using mask semantics). The data type can only be INT8. The shape needs to be calculated according to the shape inference formula of indices in the function description. are not supported. The supports ND in three dimensions and NCHW in four dimensions, which is the same as that of self. It is a user-defined mask value.
    • 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 the first-phase API aclnnMaxPool2dWithMaskGetWorkspaceSize.
    • 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:

    • aclnnMaxPool2dWithMask defaults to a deterministic implementation.
  • The input data does not support NaN and -Inf.

  • [object Object]Atlas training series products[object Object]: When the input data is FLOAT, the data is converted to FLOAT16 for computation. As a result, the accuracy drops to some extent.

  • [object Object]Atlas inference series products[object Object]: When ceilMode is set to True, the following stride scenarios are not supported:

sh>=(Hin+padding_size)/(Hout1)s_h >= (H_{in} + padding\_size) / (H_{out} - 1)

sw>=(Win+padding_size)/(Wout1)s_w >= (W_{in} + padding\_size) / (W_{out} - 1)

[object Object]

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

[object Object]