Item A — the PER-CHANNEL-BN MobileNetV2 forward graph (matches the render) #
planning/archive/mobilenetv2_close.md Item A. StableHLO.lean already has the full strided MobileNetV2
forward graph mobilenetv2FwdGraphFull + mobilenetv2FwdGraphFull_faithful — but those use scalar
bnF (one γ/β over the whole c·h·w), tied to the scalar ℝ-forward mobilenetv2Forward_full. The
operational render (tests/TestMobilenetV2Train.lean, the bnPC block) emits per-channel BN
(reduce over spatial [2,3], γ/β : Vec c). So neither existing graph is a faithful "render of a
proven graph": they compute a different function than the render.
This file closes that gap — the per-channel-BN twin of mobilenetv2FwdGraphFull:
mobilenetv2Forward_full_pc— the ℝ-forward withbnPerChannelTensor3(per-channel,γ/β : Vec c) at every BN site, same topology/stride schedule/relu6 placement asmobilenetv2Forward_full. Built from per-channel stage abbreviationsivExpandPC/ivDepthwisePC/ivDepthwiseStridedPC/ivProjectPC(per-channel mirrors ofivExpand/…/ivProject).mobilenetv2FwdGraphFullPC— the typedSHloforward graph usingbnPerChannelFtokens.mobilenetv2FwdGraphFullPC_faithful—den (graph) = mobilenetv2Forward_full_pc, viabnPerChannelF_faithful(den (bnPerChannelF …) = bnPerChannelTensor3 …, anrfllemma). Samesimp-then-unfoldrecipe asmobilenetv2FwdGraphFull_faithful.
This is the prerequisite for the structured render (Item B): now MobileNetV2 has a proven per-channel
forward graph whose pretty matches the render's forward text. Everything closes 3-axiom-clean
(tests/AuditAxioms.lean). Stride-2 flatConvStridedF/depthwiseStridedF (4 downsampling blocks) and
the residual addV skip (b2/b4) are all assembled here, not just exercised at the op level.
Expand stage, per-channel BN: relu6 ∘ bnPC ∘ conv(1×1).
Equations
- Proofs.ivExpandPC We be εe γe βe = Proofs.relu6 (mid * h * w) ∘ Proofs.bnPerChannelTensor3 mid h w εe γe βe ∘ Proofs.flatConv We be
Instances For
Depthwise stage (stride-1), per-channel BN: relu6 ∘ bnPC ∘ depthwise.
Equations
- Proofs.ivDepthwisePC Wd bd εd γd βd = Proofs.relu6 (mid * h * w) ∘ Proofs.bnPerChannelTensor3 mid h w εd γd βd ∘ Proofs.depthwiseFlat Wd bd
Instances For
Depthwise stage (stride-2 downsample), per-channel BN: relu6 ∘ bnPC ∘ depthwiseStrided.
Equations
- Proofs.ivDepthwiseStridedPC Wd bd εd γd βd = Proofs.relu6 (mid * h * w) ∘ Proofs.bnPerChannelTensor3 mid h w εd γd βd ∘ Proofs.depthwiseStride2FlatXla Wd bd
Instances For
Project (linear bottleneck) stage, per-channel BN: bnPC ∘ conv(1×1) (no relu6).
Equations
- Proofs.ivProjectPC Wp bp εp γp βp = Proofs.bnPerChannelTensor3 oc h w εp γp βp ∘ Proofs.flatConv Wp bp
Instances For
Inverted-residual body (stride-1), per-channel BN: project ∘ depthwise ∘ expand.
Equations
- Proofs.invresBodyPC We be εe γe βe Wd bd εd γd βd Wp bp εp γp βp = Proofs.ivProjectPC Wp bp εp γp βp ∘ Proofs.ivDepthwisePC Wd bd εd γd βd ∘ Proofs.ivExpandPC We be εe γe βe
Instances For
Inverted-residual body (stride-2 downsample), per-channel BN: expand SAME (at 2h×2w) →
depthwise-strided → project.
Equations
- Proofs.invresBodyStridedPC We be εe γe βe Wd bd εd γd βd Wp bp εp γp βp = Proofs.ivProjectPC Wp bp εp γp βp ∘ Proofs.ivDepthwiseStridedPC Wd bd εd γd βd ∘ Proofs.ivExpandPC We be εe γe βe
Instances For
The full MobileNetV2 forward with per-channel BN (ch7 render): strided stem (224→112) →
6 inverted-residual blocks (b1/b3/b5/b6 stride-2 downsample, b2/b4 stride-1 skip) → 1×1
conv-bn-relu6 head → global-avg-pool → dense. Per-channel-BN twin of mobilenetv2Forward_full;
matches the operational render's BN flavor.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Whole per-channel-BN MobileNetV2 forward graph at the full ch7 render dims (3×224² →
7×7×64): strided stem (flatConvStridedF, 224→112) → 6 inverted-residual blocks (b1/b3/b5/b6
stride-2 downsample via depthwiseStridedF, b2/b4 stride-1 SAME with an addV skip) → 1×1
conv-bn-relu6 head → global-avg-pool → dense. Per-channel BN (bnPerChannelF, γ/β : Vec c)
at every BN site — matches the operational render. The per-channel twin of mobilenetv2FwdGraphFull.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Full per-channel-BN MobileNetV2 forward faithfulness. The per-channel strided render graph
denotes the proven mobilenetv2Forward_full_pc. simp-based (like mobilenetv2FwdGraphFull_faithful,
so it avoids the concrete-dim isDefEq wall), with bnPerChannelF_faithful replacing bnF_faithful.
This is the "text = render of a proven graph" forward half at the render's BN flavor.