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

Auto(Sparse)ReverseDiff not supported #287

Open
gdalle opened this issue Mar 31, 2024 · 0 comments · May be fixed by #288
Open

Auto(Sparse)ReverseDiff not supported #287

gdalle opened this issue Mar 31, 2024 · 0 comments · May be fixed by #288

Comments

@gdalle
Copy link
Member

gdalle commented Mar 31, 2024

Problem:

julia> SparseDiffTools.__test_backend_loaded(ADTypes.AutoForwardDiff())
ERROR: AutoForwardDiff{nothing, Nothing}(nothing) requires ForwardDiff.jl to be loaded. Please load it.
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:35
 [2] __test_backend_loaded(ad::AutoForwardDiff{nothing, Nothing})
   @ SparseDiffTools ~/.julia/packages/SparseDiffTools/zWIg7/src/highlevel/common.jl:347
 [3] top-level scope
   @ REPL[41]:1

julia> SparseDiffTools.__test_backend_loaded(ADTypes.AutoReverseDiff())
ERROR: AutoReverseDiff(false) requires nothing.jl to be loaded. Please load it.
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:35
 [2] __test_backend_loaded(ad::AutoReverseDiff)
   @ SparseDiffTools ~/.julia/packages/SparseDiffTools/zWIg7/src/highlevel/common.jl:347
 [3] top-level scope
   @ REPL[42]:1

Solution: edit the following lines to add the ReverseDiff case

# Check Backend has been loaded
## We pay a small compile time cost for this, but it avoids cryptic error messages
@inline function __test_backend_loaded(ad::AbstractADType)
error("$(ad) requires $(__backend(ad)).jl to be loaded. Please load it.")
end
@inline __backend(ad) = nothing
@inline __backend(::Union{AutoEnzyme, AutoSparseEnzyme}) = :Enzyme
@inline __backend(::Union{AutoZygote, AutoSparseZygote}) = :Zygote
@inline __backend(::Union{AutoForwardDiff, AutoSparseForwardDiff}) = :ForwardDiff
@inline __backend(::Union{AutoPolyesterForwardDiff, AutoSparsePolyesterForwardDiff}) = :PolyesterForwardDiff
@inline __backend(::Union{AutoFiniteDiff, AutoSparseFiniteDiff}) = :FiniteDiff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant