ℝ→Float32 bridge: the ResNet-34 structural ops #
Extending the float bridge from CIFAR/BN toward ResNet-34. After the rsqrt
keystone (BnFloatBridge.lean), no new numerical primitives remain — the r34
ops are reuses or thin wrappers:
- residual skip
relu(F(x) + skip(x))— needs a two-operandadd_close(the additive peer ofmul_close);reluAdd_closeis the post-skip output. - strided conv —
flatConvStride2 = decimateFlat ∘ flatConv, so the float closeness isflatConvF_closeat the decimated coordinate. - per-channel BN —
bnPerChannelMatisbnForwardapplied per channel-row, sobnPerChannelFlat_close_ofmapsbnForward_close_ofover channels. - global-avg-pool — a per-channel mean, so
gapFlat_closereduces tobnMean_closeon the channel slice (sum_s2flattens the spatial double sum).
The remaining work for a whole-net r34_float_close is the (large, mechanical)
per-block + whole-net composition threading the inherited error through the 16
residual blocks — no new numerical content.
Rounded addition with inherited operand errors. fl(xt ⊕ yt) is within
u·(|x| + ex + |y| + ey) + (ex + ey) of the exact x + y, given
|xt − x| ≤ ex and |yt − y| ≤ ey. The additive peer of mul_close; the
residual fan-in's float budget.
Residual block output (post-skip ReLU). With the two branches bt/st
within eb/es of the real b/s (magnitudes ≤ A/B), the rounded
relu(fl(bt ⊕ st)) is within the add_close budget of relu(b + s) per
coordinate (ReLU is exact in float and 1-Lipschitz). The float closeness of
relu(F(x) + skip(x)).
The float stride-2 conv: decimate the float stride-1 conv (the float peer of
flatConvStride2 = decimateFlat ∘ flatConv).
Equations
- M.flatConvStride2F W b = Proofs.decimateFlat oc h w ∘ M.flatConvF W b
Instances For
Stride-2 conv forward budget. Decimation only selects output coordinates,
so the strided-conv closeness is flatConvF_close evaluated at the decimated
coordinate — the same conv-fan-in layerBudget.
The float XLA-SAME stride-2 conv: the ODD decimation of the float stride-1 conv (the float
peer of flatConvStride2Xla = decimateOddFlat ∘ flatConv, StridedConv.lean). The TF-origin
stems (EfficientNet-B0, MobileNetV2).
Equations
- M.flatConvStride2XlaF W b = Proofs.decimateOddFlat oc h w ∘ M.flatConvF W b
Instances For
XLA-SAME stride-2 conv forward budget — flatConvStride2F_close at the odd coordinate:
the same conv-fan-in layerBudget, since either decimation only selects outputs.
The float per-channel BN: bnForwardF per channel-row, with the per-channel
mean fμ c and inverse-stddev fistdv c. The float peer of
bnPerChannelFlat (= bnForward per row).
Equations
- M.bnPerChannelFlatF γ β fμ fistdv v = Proofs.Mat.flatten fun (c : Fin oc) => M.bnForwardF (γ c) (β c) (fμ c) (fistdv c) (Proofs.Mat.unflatten v c)
Instances For
Per-channel BN forward closeness. Each channel-row runs bnForward, so
the float per-channel BN is within bnNormBudget of bnPerChannelFlat per
entry — bnForward_close_of mapped over channels (uniform per-channel mean/
istd errors and magnitude bounds).
The float global-average-pool: per channel, the float mean of the channel's
h·w spatial slice (rounded sum, rounded /(h·w)). The float peer of
globalAvgPoolFlat.
Equations
- M.gapFlatF v ci = M.div (M.sum fun (s : Fin (h * w)) => Proofs.Tensor3.unflatten v ci (finProdFinEquiv.symm s).1 (finProdFinEquiv.symm s).2) ↑(h * w)
Instances For
Global-average-pool closeness. GAP is the per-channel spatial mean, so the
float GAP is within the bnMean_close budget of globalAvgPoolFlat per
channel (sum_s2 flattens the spatial double sum to the Fin (h·w) slice the
mean rounds).
GAP as a per-channel bnMean. globalAvgPoolFlat c h w v ci is the mean of
channel ci's spatial slice — bnMean (h·w) of the Fin (h·w)-indexed gather.
The reduction gapFlat_close performs inline, exposed so the float-bridge
magnitude/input-shift bounds (bnMean_abs_le / bnMean_input_close) apply.