- Description: Performs backpropagation of the operator.
- Deduction formula of the input tensor:
When ceilMode is set to False, the H and W dimensions in the shape of the indices tensor are derived as follows:
When ceilMode is set to True, the H and W dimensions in the shape of the out tensor are derived as follows:
If the upper left corner of the sliding window starts from the lower or right padding or goes off-bounds (no valid value can be obtained), the sliding window result is discarded. The shape of the corresponding spatial axis needs to be subtracted by 1 based on the preceding derivation formula.
Each operator has calls. First, aclnnMaxPool2dWithIndicesBackwardGetWorkspaceSize is called to obtain the workspace size required for computation and the executor that contains the operator computation process. Then, aclnnMaxPool2dWithIndicesBackward is called to perform computation.
[object Object][object Object]
Parameters:
- gradOutput (const aclTensor *, compute input): output gradient in the previous step during backpropagation, aclTensor on the device. The shape is the same as that of the forward output. are supported. The data format is the same as that of self.
- self(const aclTensor *, compute input): input data of forward propagation, aclTensor on the device. are supported.
- indices (aclTensor *, compute input): forward output index, aclTensor on the device. The shape is the same as that of the input gradOutput. It indicates the index of the maximum element in the forward output. The data format is the same as that of self.
- kernelSize (const aclIntArray *, compute input): size of the sliding window used in the pooling operation, aclIntArray on the host. The length can only be 1 or 2.
- When the number of elements in kernelSize is 1, the window size is (kernelSize[0], kernelSize[0]).
- When the number of elements in kernelSize is 2, the window size is (kernelSize[0], kernelSize[1]).
- stride (aclIntArray*, compute input): stride of the window, aclIntArray on the host. The length can only be 0, 1, or 2. When the stride length is 0, the value of stride is equal to that of kernelSize.
- When the number of elements in stride is 0, the stride length is the same as kernelSize.
- When the number of elements in stride is 1, the stride length is (stride[0], stride[0]).
- When the number of elements in stride is 2, the stride length is (stride[0], stride[1]).
- padding (const aclIntArray *, compute input): padding of the input data, indicating the padding amount in each dimension of the input. It affects how the pooling window covers the entire input tensor. It is an aclIntArray on the host. The length can only be 1 or 2.
- When the number of elements in padding is 1, the head and tail of the H and W axes are padded with
[object Object], with the padding length equal to padding[0]. - When the number of elements in padding is 2, the head and tail of the H axis are padded with
[object Object]of length padding[0], and the head and tail of the W axis are padded with[object Object]of length padding[1].
- When the number of elements in padding is 1, the head and tail of the H and W axes are padded with
- dilation (const aclIntArray *, compute input): dilation factor of the pooling operation. The dilation operation increases the distance between elements in the pooling window. It is an aclIntArray on the host.
- [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]: Only dilation (1, 1) is supported.
- ceilMode (const bool *, compute input): controls whether the output size of the pooling operation is rounded up. It is a boolean parameter on the host. If the value is True, the output shape is calculated by rounding up. If the value is False, the output shape is calculated by rounding down.
- gradInput (aclTensor *, compute output): gradient of the output for backpropagation, aclTensor on the device. The shape is the same as that of self. The data format is 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:
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 aclnnMaxPool2dWithIndicesBackwardGetWorkspaceSize.
- executor (aclOpExecutor *, input): operator executor, containing the operator computation process.
- stream (aclrtStream, input): stream for executing the task.
Returns:
Deterministic compute:
- aclnnMaxPool2dWithIndicesBackward defaults to a non-deterministic implementation. You can call aclrtCtxSetSysParamOpt to enable deterministic compute.
The input data does not support NaN and -Inf. The value of indices cannot exceed in the formula and must be greater than or equal to 0.
The following example is for reference only. For details, see .