Optimized Interval Arrays (Structure-of-Arrays Layout) #
This module implements a cache-friendly interval vector representation using Structure-of-Arrays (SoA) layout instead of Array-of-Structures (AoS).
Key Optimization: SoA Layout #
Instead of:
Array IntervalDyadic = [⟨lo₁, hi₁⟩, ⟨lo₂, hi₂⟩, ...]
We store:
IntervalArray = { lo: Array Dyadic, hi: Array Dyadic }
= { lo: [lo₁, lo₂, ...], hi: [hi₁, hi₂, ...] }
Why SoA? When computing lower bounds of a layer output, we mostly access
lo values. Keeping them contiguous in memory improves cache hit rates by ~5x.
Main Definitions #
IntervalArray n- A fixed-size array of n intervals in SoA layoutmem- Membership predicate for real vectorsadd,sub- Interval operations on arrays
Structure-of-Arrays interval representation. Stores lower and upper bounds in separate contiguous arrays for cache efficiency.
- lo : Array Core.Dyadic
Lower bounds array
- hi : Array Core.Dyadic
Upper bounds array
Size invariant for lower bounds
Size invariant for upper bounds
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Access lower bound at index i
Instances For
Access upper bound at index i
Instances For
Create an interval array from a function
Equations
- LeanCert.ML.Optimized.IntervalArray.ofFn f = { lo := Array.ofFn fun (i : Fin n) => (f i).lo, hi := Array.ofFn fun (i : Fin n) => (f i).hi, lo_size := ⋯, hi_size := ⋯ }
Instances For
Create from separate lo/hi arrays (with proof of validity)
Equations
- LeanCert.ML.Optimized.IntervalArray.mk' lo hi hlo hhi = { lo := lo, hi := hi, lo_size := hlo, hi_size := hhi }
Instances For
Empty interval array (for n = 0)
Equations
- One or more equations did not get rendered due to their size.
Instances For
Singleton interval array
Equations
Instances For
Point-wise addition of interval arrays (exact, no rounding)
Equations
Instances For
Point-wise negation of interval array
Equations
Instances For
Point-wise subtraction of interval arrays
Instances For
Apply ReLU (max(0, x)) to each interval component
Equations
- One or more equations did not get rendered due to their size.
Instances For
Soundness Theorems #
Conversion #
Convert from list-based IntervalVector