TorchLean API

NN.Runtime.Autograd.Torch.Core.Ops.ShapeReduction

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.

Shape and reduction operations #

Sum-reduce all elements to a scalar. PyTorch: x.sum().

Instances For

    Flatten a tensor to a 1D vector. PyTorch: torch.flatten.

    Instances For
      def Runtime.Autograd.Torch.Internal.EagerSession.reshape {α : Type} [TorchLean.Storage α] (s : EagerSession α) [Inhabited α] {sh1 sh2 : Spec.Shape} (x : TensorRef α sh1) (h : sh1.size = sh2.size) :
      IO (TensorRef α sh2)

      Reshape a tensor while preserving total number of elements.

      PyTorch comparison: torch.reshape / view (when valid).

      Instances For

        Swap two adjacent axes at a given depth. PyTorch analogue: x.transpose(dim, dim+1).

        Instances For
          def Runtime.Autograd.Torch.Internal.EagerSession.broadcastTo {α : Type} [TorchLean.Storage α] (s : EagerSession α) [Inhabited α] [Add α] [Zero α] {sh1 sh2 : Spec.Shape} (cb : sh1.CanBroadcastTo sh2) (x : TensorRef α sh1) :
          IO (TensorRef α sh2)

          Broadcast a tensor to a larger shape. PyTorch: implicit broadcasting / expand.

          Instances For

            Sum-reduce along axis. PyTorch: torch.sum(x, dim=axis).

            Instances For

              Mean-reduce along axis. PyTorch: torch.mean(x, dim=axis).

              Instances For