Skip to content

Commit 77e05a9

Browse files
authored
Update AD_ReverseDiff.jl
1 parent 0c05d5f commit 77e05a9

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

src/AD_ReverseDiff.jl

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,21 @@ struct ReverseDiffLogDensity{L,C} <: ADGradientWrapper
1010
end
1111

1212
"""
13-
ADgradient(:ReverseDiff, ℓ)
14-
ADgradient(Val(:ReverseDiff), ℓ)
13+
ADgradient(:ReverseDiff, ℓ; compile=Val(false), x=nothing)
14+
ADgradient(Val(:ReverseDiff), ℓ; compile=Val(false), x=nothing)
1515
1616
Gradient using algorithmic/automatic differentiation via ReverseDiff.
17+
18+
If `compile isa Val{true}`, a tape of the log density computation is created upon construction of the gradient function and used in every evaluation of the gradient.
19+
One may provide an example input `x::AbstractVector` of the log density function.
20+
If `x` is `nothing` (the default), the tape is created with input `zeros(dimension(ℓ))`.
21+
22+
By default, no tape is created.
23+
24+
!!! note
25+
Using a compiled tape can lead to significant performance improvements when the gradient of the log density
26+
is evaluated multiple times (possibly for different inputs).
27+
However, if the log density contains branches, use of a compiled tape can lead to silently incorrect results.
1728
"""
1829
function ADgradient(::Val{:ReverseDiff}, ℓ;
1930
compile::Union{Val{true},Val{false}}=Val(false), x::Union{Nothing,AbstractVector}=nothing)

0 commit comments

Comments
 (0)