Skip to content

Commit

Permalink
Adapt to pending Enzyme breaking change (#92)
Browse files Browse the repository at this point in the history
* Adapt to pending Enzyme breaking change
* Update Project.toml
  • Loading branch information
wsmoses committed Sep 16, 2024
1 parent 57c9e58 commit 9a2ae80
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ ChainRulesCore = "1.16"
DiffResults = "1"
Distributions = "0.25.111"
DocStringExtensions = "0.8, 0.9"
Enzyme = "0.12.32"
Enzyme = "0.13"
FillArrays = "1.3"
ForwardDiff = "0.10.36"
Functors = "0.4"
Expand Down
6 changes: 2 additions & 4 deletions ext/AdvancedVIEnzymeExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ end
function AdvancedVI.value_and_gradient!(
::ADTypes.AutoEnzyme, f, x::AbstractVector{<:Real}, out::DiffResults.MutableDiffResult
)
Enzyme.API.runtimeActivity!(true)
∇x = DiffResults.gradient(out)
fill!(∇x, zero(eltype(∇x)))
_, y = Enzyme.autodiff(
Enzyme.ReverseWithPrimal, Enzyme.Const(f), Enzyme.Active, Enzyme.Duplicated(x, ∇x)
Enzyme.set_runtime_activity(Enzyme.ReverseWithPrimal, true), Enzyme.Const(f), Enzyme.Active, Enzyme.Duplicated(x, ∇x)
)
DiffResults.value!(out, y)
return out
Expand All @@ -35,11 +34,10 @@ function AdvancedVI.value_and_gradient!(
aux,
out::DiffResults.MutableDiffResult,
)
Enzyme.API.runtimeActivity!(true)
∇x = DiffResults.gradient(out)
fill!(∇x, zero(eltype(∇x)))
_, y = Enzyme.autodiff(
Enzyme.ReverseWithPrimal,
Enzyme.set_runtime_activity(Enzyme.ReverseWithPrimal, true)
Enzyme.Const(f),
Enzyme.Active,
Enzyme.Duplicated(x, ∇x),
Expand Down

0 comments on commit 9a2ae80

Please sign in to comment.