Batched stages — conv/depthwise → true batch-norm (→ swish) at the batched index, with VJPs #
The building blocks every batched conv-net forward is written in, at the flat batched index
N·(c·h·w): each stage is batchMap N of a proven per-example op, then true batch-norm
(bnBatchLA, which couples the batch), then pointwise swish where the net has it.
| stage | forward | VJP |
|---|---|---|
| 1×1 / stride-1 conv → BN → swish | cbsB | cbsBHasVJP |
XLA-SAME stride-2 stem conv → BN → swish | stemB | stemBHasVJP |
| depthwise (stride 1 / symmetric stride 2) → BN → swish | dwbsB / dwbsSB | dwbsBHasVJP / dwbsSBHasVJP |
| squeeze-excite | seB | seBHasVJP |
| 1×1 projection → BN (no activation) | projB | projBHasVJP |
The generic pieces they compose — batchMapHasVJP (block-diagonal VJP of a batch-separable op)
and bnBatchLAHasVJP — are in BatchMapVJPAt. EfficientNet-B0, MobileNetV2/V4 and the ResNets
build their blocks from these; the MBConv blocks themselves are in EfficientNetRender.PC and
EfficientNetChainClose.
Batched conv → bn → swish (1×1 expand / generic stride-1 conv).
Equations
- Proofs.cbsB N W b ε γ β = Proofs.swish (N * (oc * h * w)) ∘ Proofs.StableHLO.bnBatchLA N oc h w ε γ β ∘ Proofs.StableHLO.batchMap N (Proofs.flatConv W b)
Instances For
Batched strided (3×3 s2) stem conv → bn → swish (halves spatial). Note: at the XLA-SAME
phase (flatConvStride2Xla = decimateOddFlat ∘ flatConv): the TF-origin B0 pads its stem
(0,1), and the shipped render emits convStridedXla there. The symmetric
flatConvStride2 has the same type and output shape; nothing structural would notice the
wrong one.
Equations
- Proofs.stemB N W b ε γ β = Proofs.swish (N * (oc * h * w)) ∘ Proofs.StableHLO.bnBatchLA N oc h w ε γ β ∘ Proofs.StableHLO.batchMap N (Proofs.flatConvStride2Xla W b)
Instances For
Batched depthwise (stride-1, k×k) → bn → swish.
Equations
- Proofs.dwbsB N W b ε γ β = Proofs.swish (N * (c * h * w)) ∘ Proofs.StableHLO.bnBatchLA N c h w ε γ β ∘ Proofs.StableHLO.batchMap N (Proofs.depthwiseFlat W b)
Instances For
Batched depthwise (stride-2 downsample, k×k) → bn → swish.
Equations
- Proofs.dwbsSB N W b ε γ β = Proofs.swish (N * (c * h * w)) ∘ Proofs.StableHLO.bnBatchLA N c h w ε γ β ∘ Proofs.StableHLO.batchMap N (Proofs.depthwiseStride2Flat W b)
Instances For
Batched squeeze-excite block x ⊙ gate(x) (the proven seBlockFull, per example).
Equations
- Proofs.seB N W₁ b₁ W₂ b₂ = Proofs.StableHLO.batchMap N (Proofs.seBlockFull W₁ b₁ W₂ b₂)
Instances For
Batched project: 1×1 conv → bn (no swish — the linear bottleneck).
Equations
- Proofs.projB N W b ε γ β = Proofs.StableHLO.bnBatchLA N oc h w ε γ β ∘ Proofs.StableHLO.batchMap N (Proofs.flatConv W b)
Instances For
flatConv W b VJP — the per-example 1×1/3×3 conv input-VJP (the HasVJP3-bridged conv2d).
Equations
- Proofs.flatConvHasVJP W b = (Proofs.conv2dHasVJP3 W b).toHasVJP
Instances For
Differentiability of a batched conv/depthwise → bn → swish stage.
VJP of a batched conv/depthwise → bn → swish stage: lift op's VJP per example, then the proven
true-BN VJP, then the pointwise swish VJP.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Differentiability of a batched conv → bn stage (project bottleneck, no swish).
VJP of a batched conv → bn stage.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Proofs.cbsBHasVJP N W b ε hε γ β = Proofs.bnSwishStageHasVJP N (Proofs.flatConv W b) ⋯ (Proofs.flatConvHasVJP W b) ε hε γ β
Instances For
Equations
- Proofs.stemBHasVJP N W b ε hε γ β = Proofs.bnSwishStageHasVJP N (Proofs.flatConvStride2Xla W b) ⋯ (Proofs.flatConvStride2XlaHasVJP W b) ε hε γ β
Instances For
Equations
- Proofs.dwbsBHasVJP N W b ε hε γ β = Proofs.bnSwishStageHasVJP N (Proofs.depthwiseFlat W b) ⋯ (Proofs.depthwiseFlatHasVJP W b) ε hε γ β
Instances For
Equations
- Proofs.dwbsSBHasVJP N W b ε hε γ β = Proofs.bnSwishStageHasVJP N (Proofs.depthwiseStride2Flat W b) ⋯ (Proofs.depthwiseStride2FlatHasVJP W b) ε hε γ β
Instances For
Equations
- Proofs.seBHasVJP N W₁ b₁ W₂ b₂ = Proofs.batchMapHasVJP (Proofs.seBlockFull W₁ b₁ W₂ b₂) (Proofs.seBlockFullHasVJP W₁ b₁ W₂ b₂) ⋯
Instances For
Equations
- Proofs.projBHasVJP N W b ε hε γ β = Proofs.bnStageHasVJP N (Proofs.flatConv W b) ⋯ (Proofs.flatConvHasVJP W b) ε hε γ β