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.
Linear algebra and concatenation #
def
Runtime.Autograd.Torch.Internal.EagerSession.matmul
{α : Type}
(s : EagerSession α)
[Context α]
[DecidableRel fun (x1 x2 : α) => x1 > x2]
[DecidableEq Spec.Shape]
{m n p : ℕ}
(a : TensorRef α (Spec.Shape.dim m (Spec.Shape.dim n Spec.Shape.scalar)))
(b : TensorRef α (Spec.Shape.dim n (Spec.Shape.dim p Spec.Shape.scalar)))
:
IO (TensorRef α (Spec.Shape.dim m (Spec.Shape.dim p Spec.Shape.scalar)))
2D matrix multiplication. PyTorch: torch.matmul for 2D tensors.
Instances For
def
Runtime.Autograd.Torch.Internal.EagerSession.bmm
{α : Type}
(s : EagerSession α)
[Add α]
[Mul α]
[Zero α]
[DecidableEq Spec.Shape]
{batch m n p : ℕ}
(a : TensorRef α (Spec.Shape.dim batch (Spec.Shape.dim m (Spec.Shape.dim n Spec.Shape.scalar))))
(b : TensorRef α (Spec.Shape.dim batch (Spec.Shape.dim n (Spec.Shape.dim p Spec.Shape.scalar))))
:
IO (TensorRef α (Spec.Shape.dim batch (Spec.Shape.dim m (Spec.Shape.dim p Spec.Shape.scalar))))
Batched matrix multiplication. PyTorch: torch.bmm.
Instances For
def
Runtime.Autograd.Torch.Internal.EagerSession.concatVectors
{α : Type}
(s : EagerSession α)
[Context α]
[DecidableRel fun (x1 x2 : α) => x1 > x2]
[DecidableEq Spec.Shape]
{n m : ℕ}
(a : TensorRef α (Spec.Shape.dim n Spec.Shape.scalar))
(b : TensorRef α (Spec.Shape.dim m Spec.Shape.scalar))
:
IO (TensorRef α (Spec.Shape.dim (n + m) Spec.Shape.scalar))
Concatenate two vectors along dim 0. PyTorch: torch.cat([a,b], dim=0).
Instances For
def
Runtime.Autograd.Torch.Internal.EagerSession.concatLeadingAxis
{α : Type}
(s : EagerSession α)
[DecidableEq Spec.Shape]
{n m : ℕ}
{sh : Spec.Shape}
(a : TensorRef α (Spec.Shape.dim n sh))
(b : TensorRef α (Spec.Shape.dim m sh))
:
IO (TensorRef α (Spec.Shape.dim (n + m) sh))
Concatenate along dim 0 for tensors with leading dimension. PyTorch: torch.cat(..., dim=0).
Instances For
def
Runtime.Autograd.Torch.Internal.EagerSession.sliceLeadingAxisRange
{α : Type}
(s : EagerSession α)
[Zero α]
[DecidableEq Spec.Shape]
{n : ℕ}
{sh : Spec.Shape}
(x : TensorRef α (Spec.Shape.dim n sh))
(start len : ℕ)
(h : len + start ≤ n)
:
IO (TensorRef α (Spec.Shape.dim len sh))
Slice along dim 0: x[start:start+len]. PyTorch: standard slicing.