TorchLean API

FloatLib.Floats.Formats.BinaryInterchange.Configured

Configured binary values and literals #

Import this module to use binary formats. The standard formats are Binary16, BFloat16, Binary32, Binary64, Binary128, and Binary256. Any other format is selected by its exponent and fraction widths:

def x : Binary32 := 1.5
def y : ExecFloat.Binary (exponentBits := 7) (fractionBits := 16) := 0.75

Configured.Type owns the public type constructor, the modules below Configured.Storage own packed-carrier selection and codecs, and Configured.NativeDispatch plus Configured.Plan.Instances install certified operation backends. The value-facing implementation is separated further:

Configured.Transcendentals is a named import, not part of this module: it lifts the deterministic elementary-function kernels and the power to this type, with certify := true for correctly rounded results. import FloatLib does not install ExecFloat.Binary.exp, ExecFloat.Binary.pow, Model.exp, Model.pow, or the binary MathFunctions instances.

Natural and scientific literals are rounded once from exact rationals into the destination format. They never pass through Lean's host Float, C double, or an IEEE bit-pattern parser.

Import FloatLib.Floats.Formats.BinaryInterchange.Info.Command when #float_info is also required.

References #

Plan #

Configured formats make two static decisions:

  1. StoragePlan chooses the persistent carrier from encoded width.
  2. The Configured.Plan modules choose a certified kernel independently for each operation.

The implementation is split by responsibility:

All selection is structural. Word and pair kernels declare which descriptors they serve, so layout-specific implementations are specialized without testing catalogued format names. Every supported descriptor keeps the generic kernel as a fallback.