Skip to content

Commit 75f6abe

Browse files
authored
Cache support with ForwardDiff (#590)
* Cache support with ForwardDiff * Fix rewrap
1 parent 40b629d commit 75f6abe

File tree

10 files changed

+154
-102
lines changed

10 files changed

+154
-102
lines changed

DifferentiationInterface/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "DifferentiationInterface"
22
uuid = "a0c0ee7d-e4b9-4e03-894e-1c5f64a51d63"
33
authors = ["Guillaume Dalle", "Adrian Hill"]
4-
version = "0.6.15"
4+
version = "0.6.16"
55

66
[deps]
77
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"

DifferentiationInterface/docs/src/explanation/advanced.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Right now, there are two kinds of context: [`Constant`](@ref) and [`Cache`](@ref
1919
This feature is still experimental and will not be supported by all backends.
2020
At the moment:
2121
- `Constant` is supported by all backends except symbolic ones
22-
- `Cache` is only supported by finite difference backends
22+
- `Cache` is only supported by finite difference backends and [`AutoForwardDiff`](@ref), but it is not yet optimized
2323

2424
Semantically, both of these calls compute the partial gradient of `f(x, c)` with respect to `x`, but they consider `c` differently:
2525

DifferentiationInterface/docs/src/tutorials/advanced.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ prep_other_constant = prepare_gradient(f_multiarg, backend, x, Constant(-1))
4949
gradient(f_multiarg, prep_other_constant, backend, x, Constant(10))
5050
```
5151

52+
For additional arguments which act as mutated buffers, the [`Cache`](@ref) wrapper is the appropriate choice instead of [`Constant`](@ref).
53+
5254
## Sparsity
5355

5456
Sparse AD is very useful when Jacobian or Hessian matrices have a lot of zeros.

DifferentiationInterface/ext/DifferentiationInterfaceForwardDiffExt/DifferentiationInterfaceForwardDiffExt.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ using Base: Fix1, Fix2
55
import DifferentiationInterface as DI
66
using DifferentiationInterface:
77
BatchSizeSettings,
8+
Cache,
9+
Constant,
810
Context,
911
DerivativePrep,
1012
DifferentiateWith,

0 commit comments

Comments
 (0)