JuliaDiff / SparseDiffTools.jl

Fast jacobian computation through sparsity exploitation and matrix coloring
MIT License
237 stars 41 forks source link

RFC: add auto-auto hessian #198

Closed baggepinnen closed 1 year ago

baggepinnen commented 1 year ago

This PR adds ForwardDiff over ForwardDiff for sparse color Hessians. I could not find a good way to solve the chicken-and-egg problem of initializing caches to the correct type, the inner gradient needs a cache element type with a tag that depends on the outer function and vice versa. The current code works, but postpones the creation of the cache until the first call to autoauto_color_hessian, when the cache is created and stored in a type-unstable way. I'd be happy to receive suggestions on how to properly initialize the cache objects to avoid this hack.

ChrisRackauckas commented 1 year ago

Predefine the tags. https://github.com/JuliaDiff/SparseDiffTools.jl/blob/master/src/differentiation/jaches_products.jl#L1 for the inner tag, and then out can be like HessianOuterTag or something.

baggepinnen commented 1 year ago

This should be good to go now