DML_AVERAGE_POOLING_GRAD_OPERATOR_DESC structure (directml.h)

Computes backpropagation gradients for average pooling (see DML_AVERAGE_POOLING_OPERATOR_DESC).

Consider a 2x2 DML_AVERAGE_POOLING_OPERATOR_DESC, without padding and a stride of 1, that performs the following.

InputTensor             OutputTensor
[[[[1, 2, 3],   AvgPool  [[[[3, 4],
   [4, 5, 6],     -->       [6, 7]]]]
   [7, 8, 9]]]]

Each 2x2 window in the input tensor is averaged to produce one element of the output (reading zeros for elements beyond the edge). Here's an example of the output of DML_AVERAGE_POOLING_GRAD_OPERATOR_DESC given similar parameters.

InputGradientTensor            OutputGradientTensor
  [[[[1, 2],     AvgPoolGrad  [[[[0.25, 0.75, 0.5],
     [3, 4]]]]       -->         [   1,  2.5, 1.5],
                                 [0.75, 1.75,   1]]]]

Notice that the values in the OutputGradientTensor represent the weighted contributions of that element to the OutputTensor during the original DML_AVERAGE_POOLING_OPERATOR_DESC operator.

Important

This API is available as part of the DirectML standalone redistributable package (see Microsoft.AI.DirectML version 1.4 and later. Also see DirectML version history.

Syntax

struct DML_AVERAGE_POOLING_GRAD_OPERATOR_DESC
{
  const DML_TENSOR_DESC* InputGradientTensor;
  const DML_TENSOR_DESC* OutputGradientTensor;
  UINT DimensionCount;
  _Field_size_(DimensionCount) const UINT* Strides;
  _Field_size_(DimensionCount) const UINT* WindowSize;
  _Field_size_(DimensionCount) const UINT* StartPadding;
  _Field_size_(DimensionCount) const UINT* EndPadding;
  BOOL IncludePadding;
};

Members

InputGradientTensor

Type: const DML_TENSOR_DESC*

The incoming gradient tensor. This is typically obtained from the output of backpropagation of a preceding layer. Typically this tensor would have the same sizes as the output of the corresponding DML_AVERAGE_POOLING_OPERATOR_DESC in the forward pass.

OutputGradientTensor

Type: const DML_TENSOR_DESC*

An output tensor containing the backpropagated gradients. Typically this tensor would have the same sizes as the input of the corresponding DML_AVERAGE_POOLING_OPERATOR_DESC in the forward pass.

DimensionCount

Type: UINT

The number of elements in the Strides, WindowSize, StartPadding, and EndPadding arrays. This value must equal the spatial dimension count. The spatial dimension count is 2 if 4D tensors are provided, or 3 if 5D tensors are provided.

Strides

Type: _Field_size_(DimensionCount) const UINT*

See Strides in DML_AVERAGE_POOLING_OPERATOR_DESC.

WindowSize

Type: _Field_size_(DimensionCount) const UINT*

See WindowSize in DML_AVERAGE_POOLING_OPERATOR_DESC.

StartPadding

Type: _Field_size_(DimensionCount) const UINT*

See StartPadding in DML_AVERAGE_POOLING_OPERATOR_DESC.

EndPadding

Type: _Field_size_(DimensionCount) const UINT*

See EndPadding in DML_AVERAGE_POOLING_OPERATOR_DESC.

IncludePadding

Type: BOOL

See IncludePadding in DML_AVERAGE_POOLING_OPERATOR_DESC.

Availability

This operator was introduced in DML_FEATURE_LEVEL_3_0.

Tensor constraints

InputGradientTensor and OutputGradientTensor must have the same DataType and DimensionCount.

Tensor support

Tensor Kind Supported dimension counts Supported data types
InputGradientTensor Input 4 to 5 FLOAT32, FLOAT16
OutputGradientTensor Output 4 to 5 FLOAT32, FLOAT16

Requirements

   
Header directml.h