CUDA Tape Operations: Concatenation, Slicing, and Indexing #
Concat / slice along dim 0 #
@[inline]
def
Runtime.Autograd.LibTorch.Tape.concat
{n m : ℕ}
{s : Spec.Shape}
(t : Tape SomeBuffer)
(aId bId : ℕ)
:
Result (Tape SomeBuffer × ℕ)
Concatenate along the leading dimension, preserving the common trailing shape.
Instances For
@[inline]
def
Runtime.Autograd.LibTorch.Tape.slice
{n : ℕ}
{s : Spec.Shape}
(t : Tape SomeBuffer)
(xId start len : ℕ)
(_h : start + len ≤ n)
:
Result (Tape SomeBuffer × ℕ)
Slice along the leading dimension: x[start:start+len].
Instances For
Arbitrary-axis bounded indexing #
@[reducible, inline]
An adjacent-swap depth paired with its checked CUDA representation.
Instances For
Adjacent swaps that move axis to the outermost position.
Instances For
Apply swaps to an owned buffer, releasing each consumed intermediate.
Instances For
Apply swaps to a borrowed buffer, owning only the buffers created by the swaps.
Instances For
def
Runtime.Autograd.LibTorch.Tape.Indexing.releasePermutedThen
(steps : List SwapStep)
(permuted keep : Buffer)
:
Release a permuted buffer exactly when permuteBorrowed allocated it.
Instances For
def
Runtime.Autograd.LibTorch.Tape.Indexing.finTensorToIndexArray
{n count : ℕ}
(indices : TorchLean.Tensor (Fin n) [count])
:
Convert bounded tensor indices to the host array expected by CUDA row kernels.
Instances For
@[inline]
def
Runtime.Autograd.LibTorch.Tape.select
{s : Spec.Shape}
(t : Tape SomeBuffer)
(xId axis : ℕ)
[Spec.Shape.AxisInBounds axis s]
(index : Fin (s.axisSize axis))
:
Result (Tape SomeBuffer × ℕ)
Select one bounded coordinate from any tensor axis.
Instances For
@[inline]
def
Runtime.Autograd.LibTorch.Tape.indexSelect
{s : Spec.Shape}
(t : Tape SomeBuffer)
(xId axis count : ℕ)
[Spec.Shape.AxisInBounds axis s]
(indices : TorchLean.Tensor (Fin (s.axisSize axis)) [count])
:
Result (Tape SomeBuffer × ℕ)
Select several bounded coordinates from any tensor axis.
Instances For
@[inline]
def
Runtime.Autograd.LibTorch.Tape.scatterAdd
{s : Spec.Shape}
(t : Tape SomeBuffer)
(baseId sourceId axis count : ℕ)
[Spec.Shape.AxisInBounds axis s]
(indices : TorchLean.Tensor (Fin (s.axisSize axis)) [count])
:
Result (Tape SomeBuffer × ℕ)
Add indexed source slices into any tensor axis.