Documentation

Hesper.Float16

Float16 (Half Precision) Array Support #

Direct Float16 support using raw byte arrays. No automatic conversions - all conversions must be explicit.

Hardware Requirements:

Performance Benefits:

Float16 array stored as raw bytes (2 bytes per element). Works directly with C FFI and GPU without type conversion overhead.

IMPORTANT: We store numElements explicitly because Lean cannot properly access ByteArray.size when the ByteArray is wrapped in a struct from C++.

  • data : ByteArray

    Raw byte representation (2 bytes per float16)

  • numElements : Nat

    Number of Float16 elements (NOT bytes)

Instances For

    Get number of Float16 elements

    Equations
    Instances For

      Create empty Float16Array

      Equations
      Instances For

        Create Float16Array from raw ByteArray (must be 2-byte aligned)

        Equations
        Instances For
          @[extern lean_f16_hw_check]

          Check if FP16 hardware support is available

          Equations
          • One or more equations did not get rendered due to their size.
          Instances For
            @[extern lean_f16_from_f64_array]

            ONLY for explicit conversion when needed - converts Float64 to Float16

            @[extern lean_f16_to_f64_array]

            ONLY for explicit conversion when needed - converts Float16 to Float64

            @[extern lean_f16_get]

            Get single element (converts to Float64 only for access)

            @[extern lean_f16_set]

            Set single element (converts from Float64)

            Equations
            • One or more equations did not get rendered due to their size.
            Instances For