Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix + test for compiled ReverseDiff without linking #2097

Merged
merged 1 commit into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "Turing"
uuid = "fce5fe82-541a-59a6-adf8-730c64b5f9a0"
version = "0.29.2"
version = "0.29.3"

[deps]
AbstractMCMC = "80f14c24-f653-4e6a-9b94-39d6b0f70001"
Expand Down
2 changes: 1 addition & 1 deletion src/essential/ad.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
for cache in (:true, :false)
@eval begin
function LogDensityProblemsAD.ADgradient(::ReverseDiffAD{$cache}, ℓ::Turing.LogDensityFunction)
return LogDensityProblemsAD.ADgradient(Val(:ReverseDiff), ℓ; compile=Val($cache))
return LogDensityProblemsAD.ADgradient(Val(:ReverseDiff), ℓ; compile=Val($cache), x=DynamicPPL.getparams(ℓ))

Check warning on line 121 in src/essential/ad.jl

View check run for this annotation

Codecov / codecov/patch

src/essential/ad.jl#L121

Added line #L121 was not covered by tests
end
end
end
Expand Down
14 changes: 14 additions & 0 deletions test/essential/ad.jl
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,18 @@
end
end
end

@testset "ReverseDiff compiled without linking" begin
f = DynamicPPL.LogDensityFunction(gdemo_default)
θ = DynamicPPL.getparams(f)

f_rd = LogDensityProblemsAD.ADgradient(Turing.Essential.ReverseDiffAD{false}(), f)
f_rd_compiled = LogDensityProblemsAD.ADgradient(Turing.Essential.ReverseDiffAD{true}(), f)

ℓ, ℓ_grad = LogDensityProblems.logdensity_and_gradient(f_rd, θ)
ℓ_compiled, ℓ_grad_compiled = LogDensityProblems.logdensity_and_gradient(f_rd_compiled, θ)

@test ℓ == ℓ_compiled
@test ℓ_grad == ℓ_grad_compiled
end
end
Loading