diff options
| author | Tom Smeding <tom@tomsmeding.com> | 2025-10-23 23:53:37 +0200 |
|---|---|---|
| committer | Tom Smeding <tom@tomsmeding.com> | 2025-10-23 23:53:37 +0200 |
| commit | 2542f5ef42452967fec1d2376927c1f36bf263f4 (patch) | |
| tree | 717d97be4d21c4ac0355270ac81df33296b8b852 /src/CHAD | |
| parent | f805440cf8833d238f848dd07f89b8ed5bc69e90 (diff) | |
WIP fold: Implement D[fold1i]
Still need to handle the new primitives in the rest of the library
Diffstat (limited to 'src/CHAD')
| -rw-r--r-- | src/CHAD/Accum.hs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/CHAD/Accum.hs b/src/CHAD/Accum.hs index 7212232..a7bc53f 100644 --- a/src/CHAD/Accum.hs +++ b/src/CHAD/Accum.hs @@ -44,6 +44,11 @@ d2deepZeroInfo (STArr _ t) e = emap (d2deepZeroInfo t (EVar ext (d1 t) IZ)) e d2deepZeroInfo (STScal t) _ | Refl <- lemDeepZeroInfoScal t = ENil ext d2deepZeroInfo STAccum{} _ = error "accumulators not allowed in source program" +-- The weakening is necessary because we need to initialise the created +-- accumulators with zeros. Those zeros are deep and need full primals. This +-- means, in the end, that primals corresponding to environment entries +-- promoted to an accumulator with accumPromote in CHAD need to be stored for +-- the dual. makeAccumulators :: D1E envPro :> env -> SList STy envPro -> Ex (Append (D2AcE envPro) env) t -> Ex env (InvTup t (D2E envPro)) makeAccumulators _ SNil e = e makeAccumulators w (t `SCons` envpro) e = |
