Open roflmaostc opened 3 years ago
I suppose here it could sort this out, but in general when it sees begin ... end
it concludes that you wanted an expression too complicated for the (very simple) symbolic differentiation here to handle. It can still handle them with dual numbers (and often this is no less efficient):
julia> using Zygote, ForwardDiff
julia> f1(x) = sum(@tullio res[i, j] := begin
a = x[i+2, j]
b = - 2 * x[i+1, j]
c = x[i, j]
a+b+c
end grad=Dual)
f1 (generic function with 1 method)
julia> gradient(f1, x)
([1.0 1.0 β¦ 1.0 1.0; -1.0 -1.0 β¦ -1.0 -1.0; β¦ ; -1.0 -1.0 β¦ -1.0 -1.0; 1.0 1.0 β¦ 1.0 1.0],)
I encountered this because my equation got quite lengthy.