TorchLean API

NN.Runtime.Autograd.Torch.Core.Ops.Pooling

Eager Tensor Operations #

PyTorch-style tensor operations backed by the eager CPU/CUDA tapes. These wrappers record runtime nodes, dispatch CUDA kernels when requested, and preserve the typed TensorRef surface.

Pooling operations #

def Runtime.Autograd.Torch.Internal.EagerSession.maxPool {α : Type} (s : EagerSession α) [Context α] [DecidableEq Spec.Shape] {d C : } {inSpatial kernel stride padding : Vector d} {hKernel : ∀ (i : Fin d), kernel.get i 0} (x : TensorRef α (Spec.Shape.ofList (C :: inSpatial.toList))) :
IO (TensorRef α (Spec.Shape.ofList (C :: (Spec.poolOutSpatialPad inSpatial kernel stride padding).toList)))

N-D max pooling for channels-first tensors (C, spatial...) (no batch axis).

PyTorch comparison: torch.nn.functional.max_pool1d / max_pool2d / max_pool3d depending on the spatial rank d.

Instances For
    def Runtime.Autograd.Torch.Internal.EagerSession.avgPool {α : Type} (s : EagerSession α) [Context α] [DecidableEq Spec.Shape] {d C : } {inSpatial kernel stride padding : Vector d} (hKernel : ∀ (i : Fin d), kernel.get i 0) (x : TensorRef α (Spec.Shape.ofList (C :: inSpatial.toList))) :
    IO (TensorRef α (Spec.Shape.ofList (C :: (Spec.poolOutSpatialPad inSpatial kernel stride padding).toList)))

    N-D average pooling for channels-first tensors (C, spatial...) (no batch axis).

    PyTorch comparison: torch.nn.functional.avg_pool1d / avg_pool2d / avg_pool3d depending on the spatial rank d.

    Instances For
      def Runtime.Autograd.Torch.Internal.EagerSession.smoothMaxPool {α : Type} [CudaBridge.TensorConv α] (s : EagerSession α) [Context α] [DecidableEq Spec.Shape] {d C : } {inSpatial kernel stride padding : Vector d} {hKernel : ∀ (i : Fin d), kernel.get i 0} (x : TensorRef α (Spec.Shape.ofList (C :: inSpatial.toList))) (beta : α) :
      IO (TensorRef α (Spec.Shape.ofList (C :: (Spec.poolOutSpatialPad inSpatial kernel stride padding).toList)))

      N-D smooth max pooling (log-sum-exp surrogate) for channels-first tensors (C, spatial...).

      This is a differentiable approximation to max pooling; PyTorch does not expose it as a single primitive, but it can be emulated with logsumexp over local windows. Executable backends require at least one spatial dimension and a finite, nonzero beta; evaluation uses an input-space max/min shift so the exponential weights remain stable for large finite values.

      Instances For

        2D max-pooling (no batch axis). PyTorch: torch.nn.functional.max_pool2d.

        Instances For
          def Runtime.Autograd.Torch.Internal.EagerSession.maxPool2dPad {α : Type} (s : EagerSession α) [Context α] [DecidableEq Spec.Shape] {kH kW inH inW inC stride padding : } {h1 : kH 0} {h2 : kW 0} (x : TensorRef α (Spec.Shape.dim inC (Spec.Shape.dim inH (Spec.Shape.dim inW Spec.Shape.scalar)))) :
          IO (TensorRef α (Spec.Shape.dim inC (Spec.Shape.dim (Spec.poolOutDim inH kH stride padding) (Spec.Shape.dim (Spec.poolOutDim inW kW stride padding) Spec.Shape.scalar))))

          2D max-pooling with padding (no batch axis). PyTorch: max_pool2d(..., padding=...).

          Instances For

            Smooth max-pooling (softmax pooling). Not a standard PyTorch primitive; see Torch.LinkedSession.smooth_max_pool2d. Executable backends require finite, nonzero beta and use max/min-shifted exponential weights.

            Instances For

              2D average-pooling (no batch axis). PyTorch: torch.nn.functional.avg_pool2d.

              Instances For
                def Runtime.Autograd.Torch.Internal.EagerSession.avgPool2dPad {α : Type} (s : EagerSession α) [Context α] [DecidableEq Spec.Shape] {kH kW inH inW inC stride padding : } (h1 : kH 0) (h2 : kW 0) (x : TensorRef α (Spec.Shape.dim inC (Spec.Shape.dim inH (Spec.Shape.dim inW Spec.Shape.scalar)))) :
                IO (TensorRef α (Spec.Shape.dim inC (Spec.Shape.dim (Spec.poolOutDim inH kH stride padding) (Spec.Shape.dim (Spec.poolOutDim inW kW stride padding) Spec.Shape.scalar))))

                2D average-pooling with padding (no batch axis). PyTorch: avg_pool2d(..., padding=...).

                Instances For