Ordinary calculations on the existing autograd tape #
Function.run uses this internal frontend when recording an ordinary scalar or tensor function.
Supported arithmetic, reductions and matrix products become existing Ops calls. Shared local
bindings stay shared. Eager execution records those calls on its tape; no second differentiation
engine or gradient representation is introduced.
The frontend checks equality of the translated operation recipe in Lean's kernel. No ring simplification, reassociation, precision conversion or speculative derivative is used. This equality is not a proof of a foreign backend's implementation. Analytic correctness still uses the existing local derivative laws and graph-composition theorems.
The call site's input supplies the element type and shape. Captured scalars and tensors are constants, not learnable parameters. Quotients and direct negation use the existing operation interface. Scalar conditionals inspect the current value and record only the selected branch; on GPU, this decision synchronizes to Lean. Fixed-parameter recurrences record their steps on the same tape. Neither feature supplies a derivative at a discontinuous branch boundary.
A forward value and its recorded input pullback. Backward consumes the recording;
close releases it without differentiation. The value remains usable after either operation.
- value : Tensor α output
Materialized forward value, retaining the requested element type.
- device : NN.Backend.Device
Effective device, including a precision-preserving CPU fallback.
Consume the existing tape with an explicit output cotangent.
Release an unused recording. Calling this more than once is harmless.
Instances For
Differentiate with the supplied cotangent. The default differentiates the sum of output entries. The recording is released even when backward fails; a consumed recording cannot be reused.
Instances For
An element context and a program using only the existing operation interface.
- context : Context α
- program {m : Type → Type} [Monad m] [Runtime.Autograd.Torch.Ops m α] : Runtime.ValueRef m α input → m (Runtime.ValueRef m α output)
Instances For
Lift scalar control flow through the existing balanced tensor traversal. No unselected branch is evaluated. GPU arithmetic and backward stay on the GPU; scalar decisions synchronize to Lean.
Instances For
Execute through the existing eager session, owned until backward or explicit close.
Instances For
Internal call-site translation; ordinary function definitions need no recording annotation.