CUDA Tape Operations: Shape and Reduction Nodes #
Reductions / views #
@[inline]
def
Runtime.Autograd.LibTorch.Tape.sum
{s : Spec.Shape}
(t : Tape SomeBuffer)
(xId : ℕ)
:
Result (Tape SomeBuffer × ℕ)
Reduce-sum of all entries, producing a scalar.
Instances For
@[inline]
def
Runtime.Autograd.LibTorch.Tape.flatten
{s : Spec.Shape}
(t : Tape SomeBuffer)
(xId : ℕ)
:
Result (Tape SomeBuffer × ℕ)
Flatten s into a 1D vector of length Spec.Shape.size s.
Instances For
@[inline]
def
Runtime.Autograd.LibTorch.Tape.reshape
{s₁ s₂ : Spec.Shape}
(t : Tape SomeBuffer)
(xId : ℕ)
(_h : s₁.size = s₂.size)
:
Result (Tape SomeBuffer × ℕ)
Reshape a buffer while preserving number of elements.
This is a no-copy view operation: it reuses the same contiguous buffer.
Instances For
@[inline]
def
Runtime.Autograd.LibTorch.Tape.swapAdjacentAtDepth
{s : Spec.Shape}
(t : Tape SomeBuffer)
(depth xId : ℕ)
:
Result (Tape SomeBuffer × ℕ)
Swap adjacent axes at a given depth in an N-D buffer.
If depth is out of range, this is treated as the identity (matches the spec-layer helper).
Instances For
@[inline]
def
Runtime.Autograd.LibTorch.Tape.broadcastTo
{s₁ s₂ : Spec.Shape}
(t : Tape SomeBuffer)
(cb : s₁.CanBroadcastTo s₂)
(xId : ℕ)
:
Result (Tape SomeBuffer × ℕ)
Broadcast x : s₁ to s₂.
Forward: broadcastTo.
Backward: sum-reduce broadcasted axes (reduceFromBroadcastTo).
Instances For
@[inline]
def
Runtime.Autograd.LibTorch.Tape.reduceSum
{s : Spec.Shape}
(axis : ℕ)
[_valid : Spec.Shape.HasNonemptyAxis axis s]
[_wf : s.WellFormed]
(t : Tape SomeBuffer)
(xId : ℕ)
:
Result (Tape SomeBuffer × ℕ)
Reduce-sum along axis.
Instances For
@[inline]
def
Runtime.Autograd.LibTorch.Tape.reduceMean
{s : Spec.Shape}
(axis : ℕ)
[valid : Spec.Shape.HasNonemptyAxis axis s]
[_wf : s.WellFormed]
(t : Tape SomeBuffer)
(xId : ℕ)
:
Result (Tape SomeBuffer × ℕ)
Reduce-mean along axis.