Python wrappers
Public Python APIs implemented by this engine symbols.Autograd node for N-dimensional max pooling.
Each output element is the maximum of a window of the (optionally zero-padded) input:
(extended to
axes). The forward pass also produces a tensor of argmax
indices into the flat padded-input buffer; these are saved as
saved_argmax_ and consumed by the backward pass to route each
gradient back to exactly one input element.
Attributes
schema_v1OpSchemaRegistered op (
"max_pool1d" / "max_pool2d" / "max_pool3d", AmpPolicy::KeepInput).K_int[N]Pooling window size per spatial axis.
stride_int[N]Per-axis stride (already resolved from the
0 sentinel during the forward pass).pad_int[N]Per-axis zero-padding.
saved_argmax_StorageFlat indices of the per-window winners; same logical shape as the output.
Static methods
1static
forward
→TensorImplPtrint forward(const int & x, const int (&)[N] K, const int (&)[N] stride, const int (&)[N] pad)Forward — pool each window down to its maximum element.
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] (non-overlapping windows).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 — scatter grad_out into the input positions recorded in saved_argmax_. Elements that did not win any window receive zero gradient.
Parameters
grad_outStorageUpstream gradient shaped like the forward output.
Returns
vector<Storage>Single-element vector containing dx with the original input shape.