gdalle / DifferentiationInterface.jl

An interface to various automatic differentiation backends in Julia.

Home Page:https://gdalle.github.io/DifferentiationInterface.jl/DifferentiationInterface

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Need `mode` method for SecondOrder

ElOceanografo opened this issue · comments

commented

I was trying to compare some second-order methods for Hessians using DifferentiationInterfaceTest, but found there is no mode method defined for SecondOrder backends:

julia> DifferentiationInterface.mode(SecondOrder(AutoSparseForwardDiff(), AutoReverseDiff()))
ERROR: MethodError: no method matching mode(::SecondOrder{AutoSparseForwardDiff{nothing, Nothing}, AutoReverseDiff})

Closest candidates are:
  mode(::AutoChainRules{<:ChainRulesCore.RuleConfig{>:ChainRulesCore.HasReverseMode}})
   @ DifferentiationInterfaceChainRulesCoreExt ~/.julia/packages/DifferentiationInterface/9POaB/ext/DifferentiationInterfaceChainRulesCoreExt/DifferentiationInterfaceChainRulesCoreExt.jl:17
  mode(::AutoChainRules{<:ChainRulesCore.RuleConfig{>:ChainRulesCore.HasForwardsMode}})
   @ DifferentiationInterfaceChainRulesCoreExt ~/.julia/packages/DifferentiationInterface/9POaB/ext/DifferentiationInterfaceChainRulesCoreExt/DifferentiationInterfaceChainRulesCoreExt.jl:16
  mode(::Union{AutoSparseFiniteDiff, AutoSparseZygote, AutoSparseFastDifferentiation, AutoSparseSymbolics, AutoSparseReverseDiff, AutoSparseForwardDiff, AutoSparsePolyesterForwardDiff})
   @ DifferentiationInterface ~/.julia/packages/DifferentiationInterface/9POaB/src/sparse.jl:37
  ...

Stacktrace:
 [1] top-level scope
   @ REPL[5]:1

...which causes an error when creating the table of benchmark results.

Good catch! I'll add this fix to the main branch so you can use it, but it won't be registered until next week or so because v0.3 is a big revamp