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>f(x) =sum(x)
f (generic function with 1 method)
julia> x =Hermitian(randn(2,2))
2×2 Hermitian{Float64, Matrix{Float64}}:0.656689-0.377647-0.377647-0.505356
julia> Enzyme.gradient(Enzyme.Forward, Enzyme.Const(f), x)
ERROR: ArgumentError: Cannot set a non-diagonal index in a Hermitian matrix
Stacktrace:
[1] setindex!
@ ~/.julia/juliaup/julia-1.10.5+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/LinearAlgebra/src/symmetric.jl:264 [inlined]
[2] _setindex!
@ ./abstractarray.jl:1431 [inlined]
[3] setindex!
@ ./abstractarray.jl:1396 [inlined]
[4] #93
@ ~/.julia/packages/Enzyme/TiboG/src/Enzyme.jl:967 [inlined]
[5] macro expansion
@ ./ntuple.jl:72 [inlined]
[6] ntuple(f::Enzyme.var"#93#94"{Hermitian{Float64, Matrix{Float64}}, Int64}, ::Val{4})
@ Base ./ntuple.jl:69
[7] onehot
@ ~/.julia/packages/Enzyme/TiboG/src/Enzyme.jl:963 [inlined]
[8] gradient(::EnzymeCore.ForwardMode{…}, f::EnzymeCore.Const{…}, x::Hermitian{…})
@ Enzyme ~/.julia/packages/Enzyme/TiboG/src/Enzyme.jl:1132
[9] top-level scope
@ REPL[60]:1
Some type information was truncated. Use `show(err)` to see complete types.
Types like Hermitian and Symmetric break the assumption made in onehot that all elements of the array are independent variables that can be setindex!ed freely. Not sure if there's some general solution to this, but maybe catering for stdlib types would be enough?
The text was updated successfully, but these errors were encountered:
There's a complicated but efficient solution in which onehot is smart enough only to take the independent basis elements. The real difficulty I see with that is that the output side of gradient would have to know about it to combine the results, which can potentially significantly increase its complexity.
ExpandingMan
added a commit
to ExpandingMan/Enzyme.jl
that referenced
this issue
Oct 1, 2024
Types like
Hermitian
andSymmetric
break the assumption made inonehot
that all elements of the array are independent variables that can besetindex!
ed freely. Not sure if there's some general solution to this, but maybe catering for stdlib types would be enough?The text was updated successfully, but these errors were encountered: