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
julia>using Enzyme
julia>∂(f, z) =first(first(autodiff(Reverse, f, Active, Active(z))))
∂ (generic function with 1 method)
julia> v =rand(ComplexF64, 3);
julia>∂.(exp, v)
3-element Vector{ComplexF64}:2.4742094004406776-0.6831994346902432im1.1529144463383987-0.31931177102730973im1.0208330780674268-1.295298037192365im
julia>exp.(v)
3-element Vector{ComplexF64}:2.4742094004406776+0.6831994346902432im1.1529144463383987+0.31931177102730973im1.0208330780674268+1.295298037192365im
julia>conj.(∂.(exp, v)) ≈exp.(v)
true
Note that the sign of the imaginary part is always wrong, Enzyme is basically always returning the conjugate of the correct result. The same happens with more complicate functions:
julia>f(z) = z ^ z
f (generic function with 1 method)
julia>f′(z) =f(z) * (log(z) +one(z))
f′ (generic function with 1 method)
julia> v =rand(ComplexF64, 1000);
julia>∂.(f, v) ≈f′.(v)
false
julia>conj.(∂.(f, v)) ≈f′.(v)
true
BTW, I'm not sure #547 is still an issue, I could differentiate power of complex numbers (except the result is wrong because of the conjugation).
For the record:
julia> versioninfo()
Julia Version 1.10.0
Commit 3120989f39b (2023-12-25 18:01 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: macOS (arm64-apple-darwin22.4.0)
CPU: 8 × Apple M1
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-15.0.7 (ORCJIT, apple-m1)
Threads: 1 on 4 virtual cores
(jl_30Oveo) pkg> st -m Enzyme Enzyme_jll
Status `/private/var/folders/v2/hmy3kzgj4tb3xsy8qkltxd0r0000gn/T/jl_30Oveo/Manifest.toml`
[7da242da] Enzyme v0.11.17
[7cc45869] Enzyme_jll v0.0.102+0
Slightly related (although the underlying issue is likely different), when the active argument is Complex{T<:Integer} then the result of the derivative is always zero(Complex{T}):
Note that the sign of the imaginary part is always wrong, Enzyme is basically always returning the conjugate of the correct result. The same happens with more complicate functions:
BTW, I'm not sure #547 is still an issue, I could differentiate power of complex numbers (except the result is wrong because of the conjugation).
For the record:
Slightly related (although the underlying issue is likely different), when the active argument is
Complex{T<:Integer}
then the result of the derivative is alwayszero(Complex{T})
:Results get better, but still conjugated, when converting the numbers to floating point:
As far as I understand the output of
Enzyme is just returning a tuple of zeros whatever is the input.
The text was updated successfully, but these errors were encountered: