Skip to content

Commit

Permalink
Revert "Revert "Adapt to pending Enzyme breaking change (#92)" (#93)"
Browse files Browse the repository at this point in the history
This reverts commit 5e9b84b.
  • Loading branch information
Red-Portal authored Sep 18, 2024
1 parent 5e9b84b commit fbbaddb
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 fbbaddb

Please sign in to comment.