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 #
def
Runtime.Autograd.Torch.Internal.EagerSession.sum
{α : Type}
[TorchLean.Storage α]
(s : EagerSession α)
[Add α]
[Zero α]
{sh : Spec.Shape}
(x : TensorRef α sh)
:
Sum-reduce all elements to a scalar. PyTorch: x.sum().
Instances For
def
Runtime.Autograd.Torch.Internal.EagerSession.flatten
{α : Type}
[TorchLean.Storage α]
(s : EagerSession α)
[Inhabited α]
{sh : Spec.Shape}
(x : TensorRef α sh)
:
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)
:
Reshape a tensor while preserving total number of elements.
PyTorch comparison: torch.reshape / view (when valid).
Instances For
def
Runtime.Autograd.Torch.Internal.EagerSession.swapAdjacentAtDepth
{α : Type}
[TorchLean.Storage α]
(s : EagerSession α)
{sh : Spec.Shape}
(depth : ℕ)
(x : TensorRef α sh)
:
IO (TensorRef α (sh.swapAdjacentAtDepth depth))
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)
:
Broadcast a tensor to a larger shape. PyTorch: implicit broadcasting / expand.
Instances For
def
Runtime.Autograd.Torch.Internal.EagerSession.reduceSum
{α : Type}
[TorchLean.Storage α]
(s : EagerSession α)
[Add α]
[Zero α]
[Inhabited α]
{sh : Spec.Shape}
(axis : ℕ)
[valid : Spec.Shape.HasNonemptyAxis axis sh]
[wf : sh.WellFormed]
(x : TensorRef α sh)
:
IO (TensorRef α (TorchLean.Tensor.shapeAfterSum sh axis))
Sum-reduce along axis. PyTorch: torch.sum(x, dim=axis).
Instances For
def
Runtime.Autograd.Torch.Internal.EagerSession.reduceMean
{α : Type}
[TorchLean.Storage α]
(s : EagerSession α)
[Context α]
{sh : Spec.Shape}
(axis : ℕ)
[valid : Spec.Shape.HasNonemptyAxis axis sh]
[wf : sh.WellFormed]
(x : TensorRef α sh)
:
IO (TensorRef α (TorchLean.Tensor.shapeAfterSum sh axis))
Mean-reduce along axis. PyTorch: torch.mean(x, dim=axis).