TorchLean API

NN.Runtime.Autograd.Engine.LibTorch.Ops.Core

CUDA Tape Operations: Shared Helpers #

Reject shape metadata containing a dimension outside the CUDA UInt32 ABI.

Instances For

    Fold all leading axes into a row count and keep the last axis as the column count.

    CUDA softmax/log-softmax kernels are 2D row kernels. This helper gives the shared convention used for vectors, matrices, and higher-rank tensors: softmax is always along the last axis.

    Instances For

      Broadcast a scalar CUDA buffer to outShape. Used by scalar reductions during backprop.

      Instances For

        Numerically stable softplus: max(x,0) + log1p(exp(-abs(x))).

        Instances For

          Row-wise stable softmax.

          The returned WithWorkspace owns the buffers used to compute the stable formula. Backward needs only the output, so callers can release the workspace as soon as they have consumed the forward result.

          Instances For

            Row-wise softmax VJP, centering the upstream values at a maximal probability before taking their weighted mean. This retains small derivatives at saturated outputs.

            Instances For

              Row-wise stable log-softmax.

              One maximal exponential supplies the exact unit term. The other exponentials are summed separately before log1p, retaining small tails that would disappear in log(1 + tail). Backward needs only the output; callers can release the workspace after the forward result.

              Instances For

                Row-wise log-softmax VJP. Separate the pivot contribution and use expm1 there to avoid subtracting two rounded unit probabilities. TorchLean still owns the backward formula.

                Instances For