Documentation

LeanMlir.Proofs.Codegen.EfficientNetRender.PC

The BATCHED EfficientNet-B0 block forwards and graphs (true batch-norm, matches the render) #

The EfficientNet peer of MobileNetV2StagesPC. EfficientNet's render (EfficientNetRender.Basic) emits true batch-norm (reduce μ/var over the batch+spatial axes [0,2,3] per channel — bnBatchTensor4), which couples the batch. So the forward graph here lives at the batched index N·(c·h·w) (StableHLO.batchOp/StableHLO.bnBatchF, StableHLO.Basic):

This file proves the FORWARD half — den (graph) = forward — for the stride-2 stem conv-bn-swish (stemGraphB_faithful), an MBConv1 (t=1, no expand) SE block (mbNoExpGraphB_faithful), an MBConv6 expand SE block with a stride-2 downsample (mbStridedGraphB_faithful), an MBConv6 expand SE block with an identity residual skip (mbResidGraphB_faithful), and the 1×1 conv-bn-swish head, GAP and the dense classifier (headGraphB_faithful) — all with true batch-norm and the squeeze-excite gate (seBlockFull, entering as BatchableOp.seBlock = batchMap N seBlockFull). B0's fifth block form, the stride-1 expand block with no skip, is mbExpGraphB_faithful in EfficientNetFullB0. Faithfulness is per-block (*GraphB_faithful: den (block graph) = block forward (den input)), so EfficientNetFullB0 chains the sixteen-block net without the kernel reducing it at once. All five theorems are in tests/AuditAxioms.lean's #print axioms list.

noncomputable def Proofs.mbNoExpFwdB (N : ℕ) {ic oc h w kHd kWd r : ℕ} (Wd : DepthwiseKernel ic kHd kWd) (bd : Vec ic) (εd : ℝ) (γd βd : Vec ic) (Wz₁ : Mat ic r) (bz₁ : Vec r) (Wz₂ : Mat r ic) (bz₂ : Vec ic) (Wp : Kernel4 oc ic 1 1) (bp : Vec oc) (εp : ℝ) (γp βp : Vec oc) :
Vec (N * (ic * h * w)) → Vec (N * (oc * h * w))

MBConv1 (t=1, no expand): depthwise-bn-swish → SE → project-bn. No residual (ic ≠ oc).

Equations
Instances For
    noncomputable def Proofs.mbStridedFwdB (N : ℕ) {ic mid oc h w kHd kWd r : ℕ} (We : Kernel4 mid ic 1 1) (be : Vec mid) (εe : ℝ) (γe βe : Vec mid) (Wd : DepthwiseKernel mid kHd kWd) (bd : Vec mid) (εd : ℝ) (γd βd : Vec mid) (Wz₁ : Mat mid r) (bz₁ : Vec r) (Wz₂ : Mat r mid) (bz₂ : Vec mid) (Wp : Kernel4 oc mid 1 1) (bp : Vec oc) (εp : ℝ) (γp βp : Vec oc) :
    Vec (N * (ic * (2 * h) * (2 * w))) → Vec (N * (oc * h * w))

    MBConv6 with a stride-2 downsample: expand-bn-swish (at 2h×2w) → strided depthwise-bn-swish → SE → project-bn. No residual (spatial changes).

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For
      noncomputable def Proofs.mbResidFwdB (N : ℕ) {c mid h w kHd kWd r : ℕ} (We : Kernel4 mid c 1 1) (be : Vec mid) (εe : ℝ) (γe βe : Vec mid) (Wd : DepthwiseKernel mid kHd kWd) (bd : Vec mid) (εd : ℝ) (γd βd : Vec mid) (Wz₁ : Mat mid r) (bz₁ : Vec r) (Wz₂ : Mat r mid) (bz₂ : Vec mid) (Wp : Kernel4 c mid 1 1) (bp : Vec c) (εp : ℝ) (γp βp : Vec c) :
      Vec (N * (c * h * w)) → Vec (N * (c * h * w))

      MBConv6 with an identity residual skip (s=1 ∧ ic=oc=c): x + (project ∘ SE ∘ depthwise ∘ expand)(x).

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For
        noncomputable def Proofs.headFwdB (N : ℕ) {c oc h w nC : ℕ} (Wh : Kernel4 oc c 1 1) (bh : Vec oc) (εh : ℝ) (γh βh : Vec oc) (Wfc : Mat oc nC) (bfc : Vec nC) :
        Vec (N * (c * h * w)) → Vec (N * nC)

        Head: 1×1 conv-bn-swish → global-avg-pool → dense classifier, all batched.

        Equations
        Instances For
          def Proofs.StableHLO.stemGraphB (epsStr : String) {N ic oc h w : ℕ} (Ws : Kernel4 oc ic 3 3) (bs : Vec oc) (εs : ℝ) (γs βs : Vec oc) (e : SHlo (N * (ic * (2 * h) * (2 * w)))) :
          SHlo (N * (oc * h * w))

          Stem 3×3-s2 conv → bn → swish, batched.

          Equations
          • One or more equations did not get rendered due to their size.
          Instances For
            theorem Proofs.StableHLO.stemGraphB_faithful (epsStr : String) {N ic oc h w : ℕ} (Ws : Kernel4 oc ic 3 3) (bs : Vec oc) (εs : ℝ) (γs βs : Vec oc) (e : SHlo (N * (ic * (2 * h) * (2 * w)))) :
            den (stemGraphB epsStr Ws bs εs γs βs e) = stemB N Ws bs εs γs βs (den e)
            def Proofs.StableHLO.mbNoExpGraphB (p epsStr : String) {N ic oc h w kHd kWd r : ℕ} (Wd : DepthwiseKernel ic kHd kWd) (bd : Vec ic) (εd : ℝ) (γd βd : Vec ic) (Wz₁ : Mat ic r) (bz₁ : Vec r) (Wz₂ : Mat r ic) (bz₂ : Vec ic) (Wp : Kernel4 oc ic 1 1) (bp : Vec oc) (εp : ℝ) (γp βp : Vec oc) (e : SHlo (N * (ic * h * w))) :
            SHlo (N * (oc * h * w))

            MBConv1 (no expand): dw-bn-swish → SE → project-bn, batched.

            Equations
            • One or more equations did not get rendered due to their size.
            Instances For
              theorem Proofs.StableHLO.mbNoExpGraphB_faithful (p epsStr : String) {N ic oc h w kHd kWd r : ℕ} (Wd : DepthwiseKernel ic kHd kWd) (bd : Vec ic) (εd : ℝ) (γd βd : Vec ic) (Wz₁ : Mat ic r) (bz₁ : Vec r) (Wz₂ : Mat r ic) (bz₂ : Vec ic) (Wp : Kernel4 oc ic 1 1) (bp : Vec oc) (εp : ℝ) (γp βp : Vec oc) (e : SHlo (N * (ic * h * w))) :
              den (mbNoExpGraphB p epsStr Wd bd εd γd βd Wz₁ bz₁ Wz₂ bz₂ Wp bp εp γp βp e) = mbNoExpFwdB N Wd bd εd γd βd Wz₁ bz₁ Wz₂ bz₂ Wp bp εp γp βp (den e)
              def Proofs.StableHLO.mbStridedGraphB (p epsStr : String) {N ic mid oc h w kHd kWd r : ℕ} (We : Kernel4 mid ic 1 1) (be : Vec mid) (εe : ℝ) (γe βe : Vec mid) (Wd : DepthwiseKernel mid kHd kWd) (bd : Vec mid) (εd : ℝ) (γd βd : Vec mid) (Wz₁ : Mat mid r) (bz₁ : Vec r) (Wz₂ : Mat r mid) (bz₂ : Vec mid) (Wp : Kernel4 oc mid 1 1) (bp : Vec oc) (εp : ℝ) (γp βp : Vec oc) (e : SHlo (N * (ic * (2 * h) * (2 * w)))) :
              SHlo (N * (oc * h * w))

              MBConv6 strided: expand-bn-swish (at 2h×2w) → strided dw-bn-swish → SE → project-bn, batched.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For
                theorem Proofs.StableHLO.mbStridedGraphB_faithful (p epsStr : String) {N ic mid oc h w kHd kWd r : ℕ} (We : Kernel4 mid ic 1 1) (be : Vec mid) (εe : ℝ) (γe βe : Vec mid) (Wd : DepthwiseKernel mid kHd kWd) (bd : Vec mid) (εd : ℝ) (γd βd : Vec mid) (Wz₁ : Mat mid r) (bz₁ : Vec r) (Wz₂ : Mat r mid) (bz₂ : Vec mid) (Wp : Kernel4 oc mid 1 1) (bp : Vec oc) (εp : ℝ) (γp βp : Vec oc) (e : SHlo (N * (ic * (2 * h) * (2 * w)))) :
                den (mbStridedGraphB p epsStr We be εe γe βe Wd bd εd γd βd Wz₁ bz₁ Wz₂ bz₂ Wp bp εp γp βp e) = mbStridedFwdB N We be εe γe βe Wd bd εd γd βd Wz₁ bz₁ Wz₂ bz₂ Wp bp εp γp βp (den e)
                def Proofs.StableHLO.mbResidGraphB (p epsStr : String) {N c mid h w kHd kWd r : ℕ} (We : Kernel4 mid c 1 1) (be : Vec mid) (εe : ℝ) (γe βe : Vec mid) (Wd : DepthwiseKernel mid kHd kWd) (bd : Vec mid) (εd : ℝ) (γd βd : Vec mid) (Wz₁ : Mat mid r) (bz₁ : Vec r) (Wz₂ : Mat r mid) (bz₂ : Vec mid) (Wp : Kernel4 c mid 1 1) (bp : Vec c) (εp : ℝ) (γp βp : Vec c) (e : SHlo (N * (c * h * w))) :
                SHlo (N * (c * h * w))

                MBConv6 with identity residual: addVB body skip, body = project ∘ SE ∘ dw ∘ expand, batched.

                Equations
                • One or more equations did not get rendered due to their size.
                Instances For
                  theorem Proofs.StableHLO.mbResidGraphB_faithful (p epsStr : String) {N c mid h w kHd kWd r : ℕ} (We : Kernel4 mid c 1 1) (be : Vec mid) (εe : ℝ) (γe βe : Vec mid) (Wd : DepthwiseKernel mid kHd kWd) (bd : Vec mid) (εd : ℝ) (γd βd : Vec mid) (Wz₁ : Mat mid r) (bz₁ : Vec r) (Wz₂ : Mat r mid) (bz₂ : Vec mid) (Wp : Kernel4 c mid 1 1) (bp : Vec c) (εp : ℝ) (γp βp : Vec c) (e : SHlo (N * (c * h * w))) :
                  den (mbResidGraphB p epsStr We be εe γe βe Wd bd εd γd βd Wz₁ bz₁ Wz₂ bz₂ Wp bp εp γp βp e) = mbResidFwdB N We be εe γe βe Wd bd εd γd βd Wz₁ bz₁ Wz₂ bz₂ Wp bp εp γp βp (den e)
                  def Proofs.StableHLO.headGraphB (epsStr : String) {N c oc h w nC : ℕ} (Wh : Kernel4 oc c 1 1) (bh : Vec oc) (εh : ℝ) (γh βh : Vec oc) (Wfc : Mat oc nC) (bfc : Vec nC) (e : SHlo (N * (c * h * w))) :
                  SHlo (N * nC)

                  Head: 1×1 conv-bn-swish → GAP → dense, batched.

                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For
                    theorem Proofs.StableHLO.headGraphB_faithful (epsStr : String) {N c oc h w nC : ℕ} (Wh : Kernel4 oc c 1 1) (bh : Vec oc) (εh : ℝ) (γh βh : Vec oc) (Wfc : Mat oc nC) (bfc : Vec nC) (e : SHlo (N * (c * h * w))) :
                    den (headGraphB epsStr Wh bh εh γh βh Wfc bfc e) = headFwdB N Wh bh εh γh βh Wfc bfc (den e)