Python wrappers
Public Python APIs implemented by this engine symbols.Autograd node for N-dimensional average pooling.
Each output element is the arithmetic mean of a window of the (optionally zero-padded) input. No activations need to be saved — the backward pass is a uniform scatter that distributes each output gradient over the input elements of its window.
Attributes
schema_v1OpSchemaRegistered op (
"avg_pool1d" / "avg_pool2d" / "avg_pool3d", AmpPolicy::KeepInput).K_int[N]Pooling window size per axis.
stride_int[N]Per-axis stride (already resolved from the
0 sentinel).pad_int[N]Per-axis zero-padding.
Static methods
1static
forward
→TensorImplPtrint forward(const int & x, const int (&)[N] K, const int (&)[N] stride, const int (&)[N] pad)Forward — emit the mean of each window.
Parameters
xTensorImplPtrInput of shape
(B, C, S_0, ..., S_{N-1}).Karray<int, N>Per-axis window size.
stridearray<int, N>Per-axis stride.
stride[i] == 0 defaults to K[i].padarray<int, N>Per-axis zero-padding amount.
Returns
TensorImplPtrOutput of shape (B, C, O_0, ..., O_{N-1}) with each .
Raises
ShapeMismatchIf the input rank disagrees with
N + 2 or any computed output extent is non-positive.Methods
1Backward — distribute grad_out evenly over each pooling window (each contributing element receives 1 / prod(K) of the upstream gradient).
Parameters
grad_outStorageUpstream gradient shaped like the forward output.
Returns
vector<Storage>Single-element vector containing dx.