Documentation

LeanMlir.ParamLayouts

The verified trainers' packed-parameter layouts #

One namespace per net family (MlpLayout, CnnLayout, CifarLayout, ResNet34Layout, MobileNetV2Layout, EfficientNetLayout, ConvNeXtLayout, ViTLayout): each net's (dims, initKind) list in the train step's argument order, its sizes, and the packed shape descriptors (packShapes, packXShape) the runtime passes to the FFI. Pure data — importing only LEBytes — so the spec side (VerifiedNetsCore's #guard spec.toSpecs == XLayout.specs) can read the tables without importing the runtime; IreeRuntime re-exports them.

Equations
Instances For
    Equations
    Instances For
      Equations
      Instances For
        Equations
        Instances For
          Equations
          Instances For
            Equations
            Instances For
              def packShapes (shapes : Array (Array Nat)) :

              Pack param shape descriptors: [nParams, rank0, d0..., rank1, d1..., ...] as int32 LE.

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

                Pack a single shape: [rank, d0, d1, ...] as int32 LE (for x input).

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

                              (dims, initKind) for every param, in func-arg order.

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

                                    (dims, initKind) for every param, in func-arg order.

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

                                          (dims, initKind) for every param, in func-arg order — generated from the B0 stage spec exactly as tests/TestEfficientNet*.lean blocks (stem out 32, prev threading).

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

                                                (dims, initKind) for every param, in func-arg order.

                                                ⚠ §2m moved three things at once: every LN affine went rank-0 #[] → per-channel #[c], the stem LN appeared, and the head LN went away. The first two were right; the third was not, and the note that used to sit here — "the last two nearly cancel … so a matching parameter count is a decomposition test, not an architecture check" — was the correct warning drawn at the wrong conclusion. The residue is not noise, it IS the missing layer: 28,587,592 against timm.create_model('convnext_tiny')'s 28,589,128 is short by exactly 2×768 = 1,536.

                                                ⭐ The head LN is back (2026-08-30, §7.1), so the head is GAP → LN(768) → dense as in both the paper (self.norm(x.mean([-2,-1])), nn.LayerNorm(dims[-1], eps=1e-6)) and timm (NormMlpClassifierHead). 182 param tensors; the floats are 27,827,818 at K = 10, i.e. 28,589,128 at K = 1000 — timm's count exactly.

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

                                                      (dims, initKind) for every param, in @vit_train_step func-arg order.

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