You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was trying to write a test for my proposed fix, but it did not have an inference issue in the tests. It seems like it depends on whether something else is executed before.
using ForwardDiff
using StaticArrays
using Test
sx =@SArrayrand(3,3)
addone(A) = A.+one(eltype(A))
sy =addone(sx)
sresult = DiffResults.JacobianResult(sy, sx)
ff(A)=sin.(A)
@inferred ForwardDiff.jacobian!(sresult, ff, sx) #throws the error (type instability) as reported@inferred ForwardDiff.jacobian!(sresult, addone, sx) #no error
Swapping the last two lines, interestingly, removes the error entirely.
It seems that there is some hidden state or something?
Running the following code
shows up as not type stable for me in Julia 1.8.5.
Maybe also related is this older topic on discourse https://discourse.julialang.org/t/am-i-using-diffresults-jl-correctly/35894
I think it is coming from
ForwardDiff.jl/ext/ForwardDiffStaticArraysExt.jl
Line 108 in 5bd7116
Replacing the anonymous function
d -> value(T,d)
withBase.Fix1(value,T)
fixes it for me.I can make a PR in case this is the desired solution.
The text was updated successfully, but these errors were encountered: