Documentation

LeanMlir.Spec

Spec helpers: param counting, feature queries, arch display, validation.

def fpnDetectParamShapes (oc c3 c4 c5 A tower : Nat) :

Param shapes owned by a .fpnDetect layer, in the ONE canonical order that emitTrainStepSig, the optimizer, the grad-clip list, the backward's grad-binding, NetSpec.paramShapes and heInitLayer must all agree on:

Wn3 [oc,c3], Wn4 [oc,c4], Wn5 [oc,c5]           -- neck laterals
(W [oc,oc,3,3], b [oc]) × tower, per level P3 → P4 → P5
Wh3, Wh4, Wh5 [A·15, oc]                        -- head convs
bh3, bh4, bh5 [A·15]                            -- head biases, LAST

The biases MUST stay last: NetSpec.applyDetPriorBias installs the RetinaNet prior by splicing the final 3·A·15 floats of the buffer.

Defined here (rather than in the codegen) because SpecHelpers and MlirCodegen both need it and neither should own it — a mismatch between any two of these consumers is a silent parameter-aliasing bug, not a compile error.

Equations
  • One or more equations did not get rendered due to their size.
Instances For
    Equations
    Instances For
      Equations
      Instances For
        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          Equations
          Instances For
            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
                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For
                    Equations
                    Instances For
                      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
                              • One or more equations did not get rendered due to their size.
                              Instances For

                                Output channels of a layer. Returns 0 for structural layers (pool, flatten, GAP).

                                Equations
                                Instances For

                                  Input channels expected by a layer. Returns 0 for layers that accept any input.

                                  Equations
                                  Instances For

                                    Validate that channel dimensions chain correctly through the spec. Returns none if valid, or some errorMessage describing the first mismatch.

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

                                      Validate at build time. Use as: #eval mySpec.validate!

                                      Equations
                                      Instances For
                                        inductive SummarySize :

                                        Which quantity the summary's first line reports. Bestiary entries cover images, token streams, residue chains and raw audio, and a few (NeRF) have no meaningful input extent.

                                        Instances For
                                          @[implicit_reducible]
                                          Equations
                                          @[implicit_reducible]
                                          Equations
                                          inductive ParamUnit :

                                          How params is abbreviated after the exact count. bare prints the count alone.

                                          Instances For
                                            @[implicit_reducible]
                                            Equations
                                            Equations
                                            Instances For
                                              @[implicit_reducible]
                                              Equations

                                              The shared Bestiary summary block. Every Bestiary/*.lean entry printed its own private def summarize; all 41 were the same ten lines varying only in the first line's label, the params abbreviation and an optional parenthetical on the validate : OK line.

                                              ⚠ The ── {name} ── and params<pad>: {n} lines are load-bearing, not decoration: tests/test_bestiary_params.py parses exactly those two shapes out of each binary's stdout to pin all 189 variants against tests/bestiary_params.yml (the CI drift guard in .github/workflows/certs.yml). Keep both shapes if you touch this.

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