-
-
Notifications
You must be signed in to change notification settings - Fork 212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ERROR: Can't differentiate simdloop expression #157
Comments
We should have adjoints for Separately we can probably handle |
|
Alright, fixed that specific issue. Will leave this open for the |
Not sure if this is fixed on master (couldn't get it to precompile on Julia v1.1), but I get this error on Zygote 0.2 when calling using Zygote
using Distances
gradient((a, b) -> evaluate(Euclidean(), a, b), rand(10), rand(10)) |
Yup, coming from this line. Given that |
Just one more example to show this kind of problem can be quite dangerous. julia> using Zygote
julia> using Statistics: var
julia> using LinearAlgebra: norm
julia> function loss1(x)
l1_pairs = [(1,5), (2,6), (3,7), (4,8)]
var([norm(x[i]-x[j]) for (i, j) in l1_pairs])
end
loss1 (generic function with 1 method)
julia> loss1'(randn(2,8))
2×8 Array{Float64,2}:
-0.548216 -0.76573 0.548216 0.76573 0.0 0.0 0.0 0.0
-0.801852 -0.584338 0.801852 0.584338 0.0 0.0 0.0 0.0
julia> function loss2(x) # similar function, the length of pairs are different.
l2_pairs = [(1,2), (2,3), (3,4), (4,1), (5,6), (6,7), (7,8), (8,5),
(1,6), (1, 8), (2,7), (2,5), (3,6), (3,8), (4,7),(4,5)]
var([norm(x[i]-x[j]) for (i, j) in l2_pairs])
end
loss2 (generic function with 1 method)
julia> loss2'(randn(2,8))
ERROR: Can't differentiate simdloop expression
Stacktrace:
[1] error(::String) at ./error.jl:33
[2] macro expansion at ./simdloop.jl:75 [inlined]
.... |
In most cases like this we should just add gradients for Of course it'd be nice if it worked out of the box. I don't think simd loops are hard to differentiate -- we probably just ignore the |
I tried all pasted code in this issue and no problems persist, except for the code with |
The same error message resurfaced with the above code on Julia 1.6, but not on Julia 1.5. See #897. |
The following example (from ForwardDiff.jl readme) works well on small input vectors but fails on larger ones.
If, however, the definition of
f
is changed tof(x) = sum(sin.(x)) + prod(tan.(x)) * sum(sqrt.(x))
it works
The text was updated successfully, but these errors were encountered: