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

Auto(Sparse)ReverseDiff not supported #287

@gdalle

Description

@gdalle

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions