Skip to content
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

Wrong gradient results for multiple getindex chained by foldl #1558

Open
frankwswang opened this issue Feb 13, 2025 · 1 comment
Open

Wrong gradient results for multiple getindex chained by foldl #1558

frankwswang opened this issue Feb 13, 2025 · 1 comment
Labels
ChainRules adjoint -> rrule, and further integration

Comments

@frankwswang
Copy link

MWE (tested on v0.7.4):

julia> using Zygote

julia> foo1 = x->foldl(getindex, (1, 2), init=x)
#1 (generic function with 1 method)

julia> foo1_ref = x->getindex(getindex(x, 1), 2)
#3 (generic function with 1 method)

julia> v = [[1.1, 2.2]]
1-element Vector{Vector{Float64}}:
 [1.1, 2.2]

julia> foo1(v) == foo1_ref(v) == 2.2
true

julia> Zygote.gradient(foo1_ref, v)
(ChainRules.OneElement{Float64, 1, Tuple{Int64}, Tuple{Base.OneTo{Int64}}}[[0.0, 1.0]],)

julia> Zygote.gradient(foo1, v)
(nothing,)
@mcabbott
Copy link
Member

I think this is JuliaDiff/ChainRules.jl#567 .

@ToucheSir ToucheSir added the ChainRules adjoint -> rrule, and further integration label Feb 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ChainRules adjoint -> rrule, and further integration
Projects
None yet
Development

No branches or pull requests

3 participants