Float16 (Half Precision) Array Support #
Direct Float16 support using raw byte arrays. No automatic conversions - all conversions must be explicit.
Hardware Requirements:
- ARM: Requires ARMv8.2-A with FP16 vector arithmetic
- x86_64: Requires F16C extension (Ivy Bridge+)
- Returns error if hardware support is unavailable
Performance Benefits:
- 4x memory savings vs Float64, 2x vs Float32
- SIMD width: NEON 8 halfs/op, AVX2+F16C 8 halfs/op
- Direct GPU tensor interop without conversion
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
Equations
Instances For
Create empty Float16Array
Equations
- Hesper.Float16.empty = { data := ByteArray.empty, numElements := 0 }
Instances For
Check if FP16 hardware support is available
Equations
- One or more equations did not get rendered due to their size.
Instances For
ONLY for explicit conversion when needed - converts Float64 to Float16
ONLY for explicit conversion when needed - converts Float16 to Float64
Get single element (converts to Float64 only for access)
Set single element (converts from Float64)
Equations
- One or more equations did not get rendered due to their size.