Skip to content

Commit

Permalink
Add back support for ADTypes < 1.5 (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
devmotion authored Aug 14, 2024
1 parent b3c5801 commit 013b68f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "LogDensityProblemsAD"
uuid = "996a588d-648d-4e1f-a8f0-a84b347e47b1"
authors = ["Tamás K. Papp <[email protected]>"]
version = "1.9.1"
version = "1.9.2"

[deps]
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
Expand Down
14 changes: 12 additions & 2 deletions ext/LogDensityProblemsADADTypesExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,18 @@ function LogDensityProblemsAD.ADgradient(ad::ADTypes.AutoForwardDiff{C}, ℓ) wh
end
end

function LogDensityProblemsAD.ADgradient(ad::ADTypes.AutoReverseDiff{T}, ℓ) where {T}
return LogDensityProblemsAD.ADgradient(Val(:ReverseDiff), ℓ; compile = Val(T))
# ADTypes 1.5 introduced a type parameter for `AutoReverseDiff` and deprecated the
# `compile` field
# Since Julia < 1.9 uses Requires which does not respect the ADTypes compat entry,
# we keep the version for ADTypes < 1.5 as well
@static if ADTypes.AutoReverseDiff isa UnionAll
function LogDensityProblemsAD.ADgradient(ad::ADTypes.AutoReverseDiff{T}, ℓ) where {T}
return LogDensityProblemsAD.ADgradient(Val(:ReverseDiff), ℓ; compile = Val(T))
end
else
function LogDensityProblemsAD.ADgradient(ad::ADTypes.AutoReverseDiff, ℓ)
return LogDensityProblemsAD.ADgradient(Val(:ReverseDiff), ℓ; compile = Val(ad.compile))
end
end

function LogDensityProblemsAD.ADgradient(::ADTypes.AutoTracker, ℓ)
Expand Down

2 comments on commit 013b68f

@devmotion
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/113136

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.9.2 -m "<description of version>" 013b68fd1665e9d397e60808e509e14b82d6a8b5
git push origin v1.9.2

Please sign in to comment.