TorchLean API

NN.Runtime.Autograd.Engine.LibTorch.Ops.Elementwise

CUDA Tape Operations: Elementwise Nodes #

Elementwise ops #

The backward closures below return newly allocated gradient buffers. When a derivative uses intermediate CUDA buffers, it releases those intermediates before returning the final gradient. The returned buffers are owned by the tape/gradient accumulator; workspace buffers are owned locally.

@[inline]

Pointwise addition node for two tensors with the same shape.

Instances For
    @[inline]

    Pointwise subtraction node for two tensors with the same shape.

    Instances For
      @[inline]

      Pointwise multiplication node for two tensors with the same shape.

      Instances For
        @[inline]

        Direct pointwise negation and its sign-reversing pullback.

        Instances For
          @[inline]

          Multiply by a scalar constant.

          Instances For
            @[inline]

            Pointwise absolute-value node.

            Instances For
              @[inline]

              Pointwise square-root node using the CUDA buffer derivative convention.

              Instances For
                @[inline]

                Clamp each element to [lo, hi].

                Instances For
                  @[inline]

                  Pointwise maximum node. Distinct parents split ties according to Buffer.maxBwd. Repeated references contribute the upstream value once, before graph accumulation.

                  Instances For
                    @[inline]

                    Pointwise minimum node. Distinct parents split ties according to Buffer.minBwd. Repeated references use the coalesced-contribution convention of Tape.max.

                    Instances For
                      @[inline]

                      Pointwise division node with the usual quotient-rule backward closure.

                      Instances For
                        @[inline]

                        Pointwise ReLU node with zero derivative on the nonpositive branch.

                        Instances For
                          @[inline]

                          Pointwise exponential node; backward recomputes exp x as local workspace.

                          Instances For
                            @[inline]

                            Elementwise sine with VJP cos(x) * dLdy.

                            The cosine buffer belongs to this backward call and is released after multiplication. The input and upstream gradient remain owned by the tape.

                            Instances For
                              @[inline]

                              Elementwise cosine with VJP -sin(x) * dLdy, releasing both temporary buffers.

                              Instances For
                                @[inline]

                                Pointwise natural-log node; callers are responsible for the positive-domain convention.

                                Instances For
                                  @[inline]

                                  Elementwise reciprocal 1/x.

                                  Instances For
                                    @[inline]

                                    Elementwise log(softplus(x) + ε).

                                    The caller must choose ε positive after conversion to binary32 to keep a rounded-zero softplus away from log(0). This operation does not validate ε or guarantee finite results for nonfinite inputs.

                                    Instances For
                                      @[inline]

                                      Direct sigmoid values and the input-based weighted pullback.

                                      Instances For
                                        @[inline]

                                        Direct tanh values and the input-based weighted pullback.

                                        Instances For
                                          @[inline]

                                          SiLU as one CUDA tape node. ATen evaluates the split-exponential value and local VJP.

                                          Instances For
                                            @[inline]

                                            Tanh-approximate GELU as one CUDA tape node.

                                            The adapter evaluates the staged pointwise formula with ATen operations. TorchLean records the node and owns its VJP rule through Activation.geluDerivSpec; one tape node does not imply one GPU kernel launch.

                                            Instances For
                                              @[inline]

                                              Pointwise softplus node with sigmoid derivative.

                                              Instances For