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
plane-local indices into the unpadded input (size prod(S)), with a
negative entry marking a window that saw only padding; these are saved as
saved_argmax_ and consumed by the backward pass to route each
gradient back to exactly one input element.
Attributes
schema_ v1OpSchema"max_pool1d" / "max_pool2d" / "max_pool3d", AmpPolicy::KeepInput).K_int[N]stride_int[N]0 sentinel during the forward pass).pad_int[N]saved_ argmax_StorageStatic methods
1forward
→TensorImplPtrint forward(const int & x, const int (&)[N] K, const int (&)[N] stride, const int (&)[N] pad, bool ceil_mode)Forward — pool each window down to its maximum element.
Parameters
xTensorImplPtr(B, C, S_0, ..., S_{N-1}).Karray<int, N>stridearray<int, N>stride[i] == 0 defaults to K[i] (non-overlapping windows).padarray<int, N>Returns
TensorImplPtrOutput of shape (B, C, O_0, ..., O_{N-1}) with each .
Raises
ShapeMismatchN + 2 or any computed output extent is non-positive.Methods
3Backward — scatter grad_out into the input positions recorded in saved_argmax_. Elements that did not win any window receive zero gradient.
Parameters
grad_ outStorageReturns
vector<Storage>Single-element vector containing dx with the original input shape.
Graph-mode backward — the same scatter, written in ops.