Documentation

LeanMlir.Proofs.Nets.MobileNet.MobileNetV2FullPaperEval

The paper-spec MobileNetV2 at inference — all 17 bottlenecks, forward + graph + faithfulness #

The inference twin of MobileNetV2FullB.lean, the batch-BatchNorm training forward. This file states the same seventeen-block [t,c,n,s] ladder at inference BatchNorm — frozen running statistics at all 52 sites, one shared ε, as mobilenetv2_fwd_eval does (mobilenetv2ForwardPaperEval) — and proves its typed SHlo graph denotes it (mobilenetv2FwdGraphPaperEval_faithful). Both are stated for one example (x : Vec (3 * 224 * 224)); frozen-statistics BatchNorm does not couple examples. The block weight records are IVWEval / IVWNoExpEval below; the training records IVW / IVWNoExp are MobileNetV2FullPaper.lean's.

Pure enumeration and chaining of MobileNetV2StagesPCEval.lean's four inference stage abbreviations (ivExpandPCEval / ivDepthwisePCEval / ivDepthwiseStridedPCEval / ivProjectPCEval) and its two bodies, generic in the class count. No new mathematics and no new tokens: every BatchNorm node's den is bnPerChannelEvalTensor3, proved once.

The SSA names are the eval render's. The training graph (MobileNetV2FullB) names its parameters %b{k}{e,d,p}{W,g,bt}, as the train-step render does. The eval render uses other names, and this file's graph carries them verbatim: bnEvalSite's %stnmu/%stnvar for the stem, %b{k}enmu, %b{k}dnmu, %b{k}pnmu and their nvar peers per block, %hnmu/%hnvar for the head, around irSig/irSigNoExp's %We{k}/%ge{k}/%bte{k}/%Wd{k}/%gd{k}/%btd{k}/%Wp{k}/%gp{k}/ %btp{k}, and every conv bias as %zb{c}, the zero constant the render binds it to at convBias := false. Names are pretty-printing metadata and do not enter den. FwdGraphTextTies checks the render's stem, head and one block of each kind against this file's graphs, byte for byte.

Per example, and the artifact is batched. The render writes this graph's own per-example constructors, printed at the artifact's batch B (mnv2FwdChain): each op takes a leading batch dimension and none reduces across it — frozen-statistics BatchNorm reads its μ, σ² as inputs, and the one reduction is the GAP over [2, 3], which FwdGraphTextTies also checks over the whole rendered module. So the artifact computes this forward at every example of its batch.

What it is tied to. mobilenetv2_fwd_eval.mlir: 263 inputs — %x, 158 parameter tensors (paperSig at convBias := false, so no bias slot has an argument: the render binds each conv bias to the %zb{c} zero constant) and 104 statistic slots (52 sites × μ, var) — with mobilenetv2in_fwd_eval.mlir and mobilenetv2in_fwd_eval_eps0001.mlir its 1000-class twins. The classifier here is generic in nCls and ε is a binder, so one theorem covers all three.

The artifacts are the zero-bias instance. IVWEval / IVWNoExpEval and the stem and head carry a conv-bias field per conv site, which den reads, while the graph spells each one as %zb{c}. So the three artifacts are the instance with every conv bias 0. At inference BatchNorm a conv bias does not cancel as it does under batch BN, so this is a restriction, not a reparametrisation.

Paper [t,c,n,s] spec (stem 3×3-s2 3→32 at the XLA-SAME phase; head 1×1 320→1280 → GAP → dense): (1, 16,1,1) (6, 24,2,2) (6, 32,3,2) (6, 64,4,2) (6, 96,3,1) (6,160,3,2) (6,320,1,1)

structure Proofs.IVWEval (ic mid oc : ℕ) :

Weights and running statistics of one MobileNetV2 bottleneck at inference. No per-site ε: the eval forward takes ONE shared ε, as the render emits (a single eps constant), where the training bundle IVW carries one per site. The conv biases eb, db, pb are fields, but the graph binds them to %zb{c}, so the committed evals are the instance with all three 0.

Instances For
    structure Proofs.IVWNoExpEval (ic oc : ℕ) :

    Weights and running statistics of the t=1 first bottleneck (no expand conv) at inference. As in IVWEval, the committed evals are the instance with the conv biases 0.

    Instances For

      All paper-spec MobileNetV2 parameters and running statistics at inference: stem (3×3-s2 3→32)

      • the 17 bottlenecks of the [t,c,n,s] table + head (1×1 320→1280) + dense (1280→nCls). 52 BatchNorm sites, each with its frozen μ and v.
      Instances For
        noncomputable def Proofs.ivNoExpEvalW (h w : ℕ) (ε : ℝ) {ic oc : ℕ} (p : IVWNoExpEval ic oc) :
        Vec (ic * h * w) → Vec (oc * h * w)

        t=1 bottleneck at inference (no expand, no skip): project ∘ depthwise.

        Equations
        Instances For
          noncomputable def Proofs.ivExpOnlyEvalW (h w : ℕ) (ε : ℝ) {ic mid oc : ℕ} (p : IVWEval ic mid oc) :
          Vec (ic * h * w) → Vec (oc * h * w)

          Stride-1 bottleneck WITHOUT skip (ic ≠ oc) at inference.

          Equations
          Instances For
            noncomputable def Proofs.ivResidEvalW (h w : ℕ) (ε : ℝ) {c mid : ℕ} (p : IVWEval c mid c) :
            Vec (c * h * w) → Vec (c * h * w)

            Stride-1 bottleneck WITH the identity skip at inference.

            Equations
            Instances For
              noncomputable def Proofs.ivStridedEvalW (h w : ℕ) (ε : ℝ) {ic mid oc : ℕ} (p : IVWEval ic mid oc) :
              Vec (ic * (2 * h) * (2 * w)) → Vec (oc * h * w)

              Stride-2 downsampling bottleneck at inference (XLA-SAME depthwise).

              Equations
              Instances For
                noncomputable def Proofs.mobilenetv2ForwardPaperEval {nCls : ℕ} (ε : ℝ) (w : MNV2PaperWeightsEval nCls) (x : Vec (3 * 224 * 224)) :
                Vec nCls

                The seventeen-block MobileNetV2 inference forward — the paper [t,c,n,s] ladder with frozen running statistics at all 52 BatchNorm sites, at one shared ε. Nested-application form (NOT ∘), as the training twin, so the faithfulness proof closes by simp and rfl.

                Equations
                • One or more equations did not get rendered due to their size.
                Instances For
                  def Proofs.StableHLO.ivNoExpGraphEvalW (k epsStr : String) (h w : ℕ) (ε : ℝ) {ic oc : ℕ} (p : IVWNoExpEval ic oc) (e : SHlo (ic * h * w)) :
                  SHlo (oc * h * w)

                  t=1 bottleneck inference graph: bnEval ∘ conv1×1 ∘ relu6 ∘ bnEval ∘ depthwise.

                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For
                    theorem Proofs.StableHLO.ivNoExpGraphEvalW_faithful (k epsStr : String) (h w : ℕ) (ε : ℝ) {ic oc : ℕ} (p : IVWNoExpEval ic oc) (e : SHlo (ic * h * w)) :
                    den (ivNoExpGraphEvalW k epsStr h w ε p e) = ivNoExpEvalW h w ε p (den e)
                    def Proofs.StableHLO.ivExpOnlyGraphEvalW (k epsStr : String) (h w : ℕ) (ε : ℝ) {ic mid oc : ℕ} (p : IVWEval ic mid oc) (e : SHlo (ic * h * w)) :
                    SHlo (oc * h * w)

                    Stride-1 no-skip bottleneck inference graph: expand → depthwise → project.

                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For
                      theorem Proofs.StableHLO.ivExpOnlyGraphEvalW_faithful (k epsStr : String) (h w : ℕ) (ε : ℝ) {ic mid oc : ℕ} (p : IVWEval ic mid oc) (e : SHlo (ic * h * w)) :
                      den (ivExpOnlyGraphEvalW k epsStr h w ε p e) = ivExpOnlyEvalW h w ε p (den e)
                      def Proofs.StableHLO.ivResidGraphEvalW (k epsStr : String) (h w : ℕ) (ε : ℝ) {c mid : ℕ} (p : IVWEval c mid c) (e : SHlo (c * h * w)) :
                      SHlo (c * h * w)

                      Stride-1 skip bottleneck inference graph: the body + the addV identity skip.

                      Equations
                      Instances For
                        theorem Proofs.StableHLO.ivResidGraphEvalW_faithful (k epsStr : String) (h w : ℕ) (ε : ℝ) {c mid : ℕ} (p : IVWEval c mid c) (e : SHlo (c * h * w)) :
                        den (ivResidGraphEvalW k epsStr h w ε p e) = ivResidEvalW h w ε p (den e)
                        def Proofs.StableHLO.ivStridedGraphEvalW (k epsStr : String) (h w : ℕ) (ε : ℝ) {ic mid oc : ℕ} (p : IVWEval ic mid oc) (e : SHlo (ic * (2 * h) * (2 * w))) :
                        SHlo (oc * h * w)

                        Stride-2 downsampling bottleneck inference graph: expand at 2h×2w → XLA-SAME strided depthwise → project.

                        Equations
                        • One or more equations did not get rendered due to their size.
                        Instances For
                          theorem Proofs.StableHLO.ivStridedGraphEvalW_faithful (k epsStr : String) (h w : ℕ) (ε : ℝ) {ic mid oc : ℕ} (p : IVWEval ic mid oc) (e : SHlo (ic * (2 * h) * (2 * w))) :
                          den (ivStridedGraphEvalW k epsStr h w ε p e) = ivStridedEvalW h w ε p (den e)
                          def Proofs.StableHLO.mnv2StemGraphPaperEval (epsStr : String) (ε : ℝ) {ic oc h w : ℕ} (W : Kernel4 oc ic 3 3) (b γ β μ v : Vec oc) (e : SHlo (ic * (2 * h) * (2 * w))) :
                          SHlo (oc * h * w)

                          Stem inference graph: 3×3/s2 XLA-SAME conv → BN (stn) → relu6.

                          Equations
                          • One or more equations did not get rendered due to their size.
                          Instances For
                            def Proofs.StableHLO.mnv2HeadGraphPaperEval (epsStr : String) (ε : ℝ) {c oc h w nC : ℕ} (W : Kernel4 oc c 1 1) (b γ β μ v : Vec oc) (Wfc : Mat oc nC) (bfc : Vec nC) (e : SHlo (c * h * w)) :
                            SHlo nC

                            Head inference graph: 1×1 conv → BN (hn) → relu6 → GAP → dense.

                            Equations
                            • One or more equations did not get rendered due to their size.
                            Instances For
                              def Proofs.StableHLO.mobilenetv2FwdGraphPaperEval {nCls : ℕ} (epsStr : String) (ε : ℝ) (w : MNV2PaperWeightsEval nCls) (x : Vec (3 * 224 * 224)) :
                              SHlo nCls

                              The full paper-spec MobileNetV2 inference forward graph (3×224² → nCls): XLA-SAME strided stem → the 17 bottlenecks of the [t,c,n,s] table → 1×1 conv-bn-relu6 head → GAP → dense, every one of the 52 BatchNorm sites reading frozen running statistics through bnPerChannelEvalF. The typed form of the shipped mobilenetv2_fwd_eval.

                              Equations
                              • One or more equations did not get rendered due to their size.
                              Instances For

                                Seventeen-block inference MobileNetV2 forward faithfulness. The typed graph denotes mobilenetv2ForwardPaperEval, for every shared ε, weight record and input example.