Skip to content

Wrong gradient results for multiple getindex chained by foldl #1558

@frankwswang

Description

@frankwswang

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,)

Metadata

Metadata

Assignees

No one assigned

    Labels

    ChainRulesadjoint -> rrule, and further integration

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions