BackwardDot #
Conv2D backward dot-level correctness (bridge lemma).
The runtime autograd engine (NN.Runtime.Autograd.Engine) computes Conv2D gradients via the
handwritten spec:
Spec.conv2d_backward_spec(kernel/bias/input)
For the analytic spec-level theorem over ℝ, Conv2D is already covered via fderiv/adjoints in:
That file provides a proof-only Conv2D node whose VJP is (fderiv forward)†, so any DAG using it
is covered by the global theorem Graph.backpropVec_eq_adjoint_fderiv.
What remains here is the dot/adjointness bridge:
$$ \operatorname{dot}(\operatorname{JVP}_{\mathrm{conv2d}}(\ldots),\delta) =\operatorname{dot}(dK,g_K)+\operatorname{dot}(dB,g_B)+\operatorname{dot}(dX,g_X). $$
Here (gK, gB, gX) is the tuple returned by Spec.conv2d_backward_spec for $\delta$.
The padding-related rewrites needed for the input-gradient proof are factored into:
NN/Spec/Layers/Utils.lean(get_at_or_zero_pad_multi_channel*lemmas)
Broadcast a bias gradient outC across spatial axes into an outC×outH×outW tensor.
Instances For
Reorder the eight indices used when expanding the Conv2D input adjoint.
paddedInput matches the forward spec’s padding convention:
- if
padding = 0, it is just a shape cast; and - otherwise it is
pad_multi_channel.
PyTorch analogue: torch.nn.functional.pad (or implicit padding inside conv2d).
https://pytorch.org/docs/stable/generated/torch.nn.functional.pad.html
https://pytorch.org/docs/stable/generated/torch.nn.functional.conv2d.html
Instances For
Collapse the shifted input indicator while carrying a constant scalar factor.
Output shape helpers (no dilation): these are the standard “convolution arithmetic” formulas. They are kept as definitions so later statements can share the same expression.
Output width helper (no dilation).