Open YichengDWu opened 2 years ago
This issue seems to persist. Is it being worked on?
It is not. It's a bit tricky to do but if someone wants to put together a fully out of place version,
using FiniteDiff, Zygote
function f(x,p)
hess = FiniteDiff.finite_difference_hessian(y -> sum(y.^3), x,
FiniteDiff.HessianCache(x, Val(:hcentral), false))
return hess * p
end
x=rand(3)
p=rand(3)
f(x,p)
Zygote.gradient(p->sum(f(x,p)), p)[1]
in theory that call should work. Right now it fails at
ArrayInterface.allowed_setindex!(H,(f(_xpp) - 2*fx + f(_xmm)) / epsilon^2,i,i)
ArrayInterface.allowed_setindex!(H,(f(_xpp) - f(_xpm) - f(_xmp) + f(_xmm))/(4*epsiloni*epsilonj),i,j)
i.e. the allowed_setindex calls which are used for a reason. If you're going to do it without this, then you need to build up all of the values in a map operation. It would probably be best to just write that as a separate dispatch for the inplace=false
case.