Skip to content

hcat rule is wrong for [I array] #810

Open
@mcabbott

Description

@mcabbott

In expressions like this, hcat figures out the size of I automatically, but the rrule assumes it behaves like a number:

julia> y = hcat(I, 11:13)
3×4 Matrix{Int64}:
 1  0  0  11
 0  1  0  12
 0  0  1  13

julia> using ChainRules: rrule, unthunk

julia> dy = reshape(1:12, 3, 4)
3×4 reshape(::UnitRange{Int64}, 3, 4) with eltype Int64:
 1  4  7  10
 2  5  8  11
 3  6  9  12

julia> rrule(hcat, I, 11:13)[2](dy) .|> unthunk
(ChainRulesCore.NoTangent(), ChainRulesCore.NoTangent(), [4.0, 5.0, 6.0])

Bug seen here: https://discourse.julialang.org/t/jacobian-vectors-in-zygote/121381 . Originally introduced in #614.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions