TorchLean API

NN.Spec.Layers.Pooling.PaddedTwoD

Padded Two-Dimensional Pooling #

These definitions expose the conventional two-dimensional, channel-first API for symmetric padding. The numerical semantics come from NN.Spec.Layers.Pooling.ND: max pooling ignores padded cells, while average pooling includes padded zeros in the divisor. This file contains only dependent-shape adapters and therefore cannot drift from the N-dimensional implementation.

def Spec.maxPool2dMultiSpecPad {α : Type} [Context α] {kH kW inH inW inC stride padding : } {h1 : kH 0} {h2 : kW 0} {hStride : stride 0} (layer : MaxPool2DSpec kH kW stride h1 h2 hStride) (input : Tensor α (Shape.dim inC (Shape.dim inH (Shape.dim inW Shape.scalar)))) :
Tensor α (pool2dMultiOutShapePad inC inH inW kH kW stride padding)

Channel-first two-dimensional max pooling with symmetric padding.

Instances For
    def Spec.maxPool2dMultiLinearizationSpecPad {α : Type} [Context α] {kH kW inH inW inC stride padding : } {h1 : kH 0} {h2 : kW 0} {hStride : stride 0} (layer : MaxPool2DSpec kH kW stride h1 h2 hStride) (input tangent : Tensor α (Shape.dim inC (Shape.dim inH (Shape.dim inW Shape.scalar)))) :
    Tensor α (pool2dMultiOutShapePad inC inH inW kH kW stride padding)

    Selected-branch JVP for padded channel-first two-dimensional max pooling.

    Instances For
      def Spec.avgPool2dMultiSpecPad {α : Type} [Context α] {kH kW inH inW inC stride padding : } (h1 : kH 0) (h2 : kW 0) {hStride : stride 0} (layer : AvgPool2DSpec kH kW stride h1 h2 hStride) (input : Tensor α (Shape.dim inC (Shape.dim inH (Shape.dim inW Shape.scalar)))) :
      Tensor α (pool2dMultiOutShapePad inC inH inW kH kW stride padding)

      Channel-first average pooling with symmetric zero padding and count_include_pad = true.

      Instances For
        def Spec.maxPool2dMultiBackwardSpecPad {α : Type} [Context α] {kH kW inH inW inC stride padding : } {h1 : kH 0} {h2 : kW 0} {hStride : stride 0} (layer : MaxPool2DSpec kH kW stride h1 h2 hStride) (input : Tensor α (Shape.dim inC (Shape.dim inH (Shape.dim inW Shape.scalar)))) (grad_output : Tensor α (pool2dMultiOutShapePad inC inH inW kH kW stride padding)) :

        VJP for padded channel-first two-dimensional max pooling.

        Instances For
          def Spec.avgPool2dMultiBackwardSpecPad {α : Type} [Context α] {kH kW inH inW inC stride padding : } (h1 : kH 0) (h2 : kW 0) {hStride : stride 0} (layer : AvgPool2DSpec kH kW stride h1 h2 hStride) (grad_output : Tensor α (pool2dMultiOutShapePad inC inH inW kH kW stride padding)) :

          VJP for padded channel-first average pooling with count_include_pad = true.

          Instances For

            Smooth max VJPs #

            def Spec.smoothMaxPool2dBackwardSpec {α : Type} [Context α] {kH kW inH inW stride : } {h1 : kH 0} {h2 : kW 0} {hStride : stride 0} (_layer : MaxPool2DSpec kH kW stride h1 h2 hStride) (beta : α) (input : Tensor α (Shape.dim inH (Shape.dim inW Shape.scalar))) (grad_output : Tensor α (pool2dOutShape inH inW kH kW stride)) :

            VJP for unpadded single-channel smooth max pooling.

            Instances For
              def Spec.smoothMaxPool2dMultiBackwardSpec {α : Type} [Context α] {kH kW inH inW inC stride : } {h1 : kH 0} {h2 : kW 0} {hStride : stride 0} (layer : MaxPool2DSpec kH kW stride h1 h2 hStride) (beta : α) (input : Tensor α (Shape.dim inC (Shape.dim inH (Shape.dim inW Shape.scalar)))) (grad_output : Tensor α (pool2dMultiOutShape inC inH inW kH kW stride)) :

              VJP for unpadded channel-first smooth max pooling.

              Instances For