Autograd node for the multi-axis reduction maximum .
The gradient routes only to positions where equals the
reduced maximum. The equality mask is built without a dedicated
equality kernel by composing two ge masks
(). Ties (multiple equal maxima)
receive equal gradient — matching the reference framework's
behaviour. The forward output is saved so the mask can be formed
without rerunning the reduction.
Math
Attributes
schema_ v1OpSchema"max" with AmpPolicy::KeepInput — integer dtypes pass through unchanged.kSavesOutputbooltrue.Notes
Empty reductions propagate NaN / raise (backend-dependent); callers should guard against zero-sized reduction axes.
Static methods
1Methods
2Backward — argmax-indicator gradient: routes grad_out only to positions where equals the reduced max (ties share equally).
Graph-mode scaling. Without this the base class returns the broadcast gradient unchanged — the sum rule — so create_graph=True silently produced the incoming seed at every position while eager backward was correct.