[object Object]

[object Object][object Object]undefined
[object Object]
  • Description: Performs backpropagation of forward adaptive max pooling. The gradient is backfilled to the coordinate of the maximum value in each adaptive window. The coordinates are accumulated.
  • Forward propagation formula: For the input self with shape [N,C,H,W][N, C, H, W], where N indicates the batch size, C indicates the number of feature map channels, H indicates the feature map height, and W indicates the feature map width. In the scenario where outputSize is [Ho,Wo][H_o, W_o], the output shape is [N,C,Ho,Wo][N, C, H_o, W_o] and the shape of indices is [N,C,Ho,Wo][N, C, H_o, W_o]. The calculation formula for each element in the corresponding tensor is as follows:Hleftm=(mH)/HoHrightm=(mH)/HoWleftn=(nW)/WoWrightn=(nW)/Wooutput(N,C,l,m,n)=maxi,j[Hleftm,Hrightm],k[Wleftn,Wrightn]input(N,C,i,j,k)indices(N,C,l,m,n)=argmaxi,j[Hleftm,Hrightm],k[Wleftn,Wrightn]input(N,C,i,j,k)H_{left}^m = \lfloor(m*H)/H_o\rfloor \\ H_{right}^m = \lceil(m*H)/H_o\rceil \\ W_{left}^n = \lfloor(n*W)/W_o\rfloor \\ W_{right}^n = \lceil(n*W)/W_o\rceil \\ output(N,C,l,m,n) = \mathop{\max}\limits_{i \in ,j\in[H_{left}^m,H_{right}^m],k\in[W_{left}^n,W_{right}^n]} input(N,C,i,j,k) \\ indices(N,C,l,m,n) = \mathop{\arg\max}\limits_{i \in ,j\in[H_{left}^m,H_{right}^m],k\in[W_{left}^n,W_{right}^n]} input(N,C,i,j,k)
[object Object]

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

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

    • gradOutput (aclTensor *, compute input): gradient tensor, which is an aclTensor on the device. The data type can be FLOAT32, FLOAT16, or BFLOAT16, and the shape is the same as that of the forward output. are supported. The can be ND. When the input is 4D, it is processed as NCHW. When the input is 3D, it is padded with 1s in dimension 0 and processed as NCHW.

    • self (aclTensor *, compute input): forward input tensor, which is an aclTensor on the device. The data type can be FLOAT32, FLOAT16, or BFLOAT16. are supported. The can be ND. When the input is 4D, it is processed as NCHW. When the input is 3D, it is padded with 1s in dimension 0 and processed as NCHW, same as that of gradOutput.

    • indices (aclTensor *, compute input): input tensor, which is an aclTensor on the device. The data type can be INT32 or INT64. It indicates the index of the maximum element in the forward input. The must be the same as that of gradOutput. The shape is the same as that of gradOutput.

    • gradInput (aclTensor *, compute output): reverse output tensor, which is an aclTensor on the device. The data type can be FLOAT32, FLOAT16, or BFLOAT16, and the shape is same as that of self. are supported. The must be the same as that of self.

    • 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 aclnnAdaptiveMaxPool2dBackwardGetWorkspaceSize.
    • 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:

    • aclnnAdaptiveMaxPool2dBackward defaults to a non-deterministic implementation. You can call aclrtCtxSetSysParamOpt to enable deterministic compute.
  • In the case of non-integer division (the remainder of the dimension values of the last two dimensions of self divided by the dimension values of the last two dimensions of gradOutput is not 0), the shape cannot exceed 2 to the power of 24. If the shape is exactly divisible, there is no such restriction.

  • Example of integer division: self = [a, b, c, d], gradOutput = [a, b, e, f]. If c%e is 0 and d%f is 0, it is an integer division scenario.

[object Object]

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

[object Object]