Skip to content

Commit b70edec

Browse files
authored
Add docs for memoization (#132)
* Add docs for memoization * Add package in example
1 parent 2e377d5 commit b70edec

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

docs/src/faq.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,14 @@ In case these operators are too complicated to code them yourself, here are a fe
114114
- [ProximalOperators.jl](https://github.com/JuliaFirstOrder/ProximalOperators.jl)
115115

116116
An alternative is differentiating through the KKT conditions, which is exactly what [DiffOpt.jl](https://github.com/jump-dev/DiffOpt.jl) does for JuMP models.
117+
118+
### Memoization
119+
120+
In some cases, performance might be increased by using memoization to prevent redundant calls to `forward`.
121+
For instance, this is relevant when calculating large Jacobians with forward differentiation, where the computation happens in [chunks](https://juliadiff.org/ForwardDiff.jl/stable/user/advanced/#Configuring-Chunk-Size).
122+
Packages such as [Memoize.jl](https://github.com/JuliaCollections/Memoize.jl) and [Memoization.jl](https://github.com/marius311/Memoization.jl) are useful for defining a memoized version of `forward`:
123+
124+
```julia
125+
using Memoize
126+
@memoize Dict forward(x, args...; kwargs...) = y
127+
```

0 commit comments

Comments
 (0)