TorchLean API

NN.Runtime.Autograd.Engine.Cuda.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.

Pointwise addition node for two tensors with the same shape.

Instances For

    Pointwise subtraction node for two tensors with the same shape.

    Instances For

      Pointwise multiplication node for two tensors with the same shape.

      Instances For

        Multiply by a scalar constant.

        Instances For

          Pointwise absolute-value node.

          Instances For

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

            Instances For

              Clamp each element to [lo, hi].

              Instances For

                Pointwise maximum node; the backward rule splits ties according to Buffer.maxBwd.

                Instances For

                  Pointwise minimum node; the backward rule splits ties according to Buffer.minBwd.

                  Instances For

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

                    Instances For

                      Pointwise ReLU node with zero derivative on the nonpositive branch.

                      Instances For

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

                        Instances For

                          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

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

                            Instances For

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

                              Instances For

                                Elementwise reciprocal 1/x.

                                Instances For

                                  Elementwise "safe log" that protects against log(0) by adding a small ε internally.

                                  Spec semantics: log(softplus(x) + ε).

                                  Instances For

                                    Elementwise sigmoid (logistic).

                                    Instances For

                                      Pointwise hyperbolic tangent node.

                                      Instances For

                                        Tanh-approximate GELU as one CUDA tape node.

                                        The native kernels fuse only the pointwise numerical work. TorchLean still records the node and owns its VJP rule through Activation.geluDerivSpec.

                                        Instances For

                                          Pointwise softplus node with sigmoid derivative.

                                          Instances For