Runtime Scalar Selection #
Runtime commands may choose Lean Float, executable IEEE binary32, complex binary32, or exact
real-number semantics. DType records that choice. FromFloat supplies the one additional
operation needed by commands that construct values from host Float literals.
Model definitions remain polymorphic over the existing Context α interface. The runtime dtype
does not replace that mathematical interface; it selects a concrete scalar type that satisfies it.
Generic host-float injection for TorchLean scalar backends.
Instances For
Float is already the host literal type, so injection is identity.
Inject host Float literals into the executable IEEE-754 binary32 backend.
Inject host literals into the dual-number backend used by the runtime autograd engine.
We interpret a literal as a primal value with zero tangent/adjoint component.
Allow numeric literals like 0.1 to elaborate to any TorchLean runtime scalar backend.
Configuration for the float32 dtype option.
We support both:
- proof-only float32 semantics (
mode = .fp32, noncomputable), and - executable IEEE-754 float32 semantics (
mode = .ieee754Exec).
- mode : Floats.Float32Mode
Which float32 semantics backend to use.
Instances For
Instances For
Scalar type choice for runnable executables.
This is a runtime selection mechanism used by example programs; the core library itself is
parametric in the scalar type α.
PyTorch Mapping #
This corresponds loosely to choosing dtype= in PyTorch, but with additional "proof-only"
variants:
.floatuses Lean's builtinFloat(executable, but its IEEE-754 behavior is trusted),.float32uses TorchLean's float32 model (either proof-only or executable),.complexuses TorchLean's parametric complex scalar over a float32 backend,.realusesℝ(proof-only; not executable).
- float : DType
- float32 (cfg : Float32Config := { }) : DType
- complex (cfg : Float32Config) : DType
- real : DType
Instances For
Instances For
Whether this dtype can be used in an executable (IO/#eval) context.
Instances For
Log a short description of the chosen dtype to stdout.
Instances For
Parse a float32 mode selector string into a Float32Mode.
Instances For
Parse and remove dtype flags from CLI arguments, using default when no dtype flags are provided.
This is the same parsing logic as parseAndStrip, but it lets higher-level runners choose a
different default dtype depending on context (e.g. CUDA eager requires Float).
Instances For
Run k under the scalar type selected by dt.
If dt is proof-only, this returns an error rather than trying to execute noncomputable code.
Instances For
Run k under the scalar type selected by dt, passing an explicit cast function Float → α.
This is a convenient shape for executables that construct tensors from Float lists.