Skip to content
This repository was archived by the owner on Apr 23, 2025. It is now read-only.

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant