TorchLean API

NN.Runtime.Autograd.Engine.LibTorch.Ops.SelectiveScan

Native diagonal scan tape nodes #

Both coefficient layouts return all states after their updates. Their backward closures retain the forward states and accumulate into all four parents. The variable-coefficient kernel returns one gradient per token; the shared-coefficient kernel sums those contributions across time. The native implementation uses a parallel affine prefix scan for eligible inputs, with a sequential recurrence fallback for expansive or nonfinite inputs and nonfinite parallel results. Reassociation can change floating-point rounding; the capsule leaves reduction order unspecified.

@[inline]
def Runtime.Autograd.LibTorch.Tape.Internal.diagonalScan (variableCoefficients : Bool) {seqLen state : ℕ} (t : Tape SomeBuffer) (aId bId xId initialId : ℕ) :

Common recording and shape checks for the two diagonal-scan coefficient layouts.

Instances For
    @[inline]
    def Runtime.Autograd.LibTorch.Tape.selectiveScanDiag {seqLen state : ℕ} (t : Tape SomeBuffer) (aId bId xId initialId : ℕ) :

    Record the recurrence with coefficient vectors shared across time.

    Instances For
      @[inline]
      def Runtime.Autograd.LibTorch.Tape.selectiveScanDiagVar {seqLen state : ℕ} (t : Tape SomeBuffer) (aId bId xId initialId : ℕ) :

      Record the recurrence with independent coefficient rows for every token.

      Instances For