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

hcat rule is wrong for [I array] #810

Open
mcabbott opened this issue Oct 16, 2024 · 0 comments
Open

hcat rule is wrong for [I array] #810

mcabbott opened this issue Oct 16, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@mcabbott
Copy link
Member

mcabbott commented Oct 16, 2024

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.

@mcabbott mcabbott added the bug Something isn't working label Oct 16, 2024
@mcabbott mcabbott changed the title 'hcat rule is wrong for [I array]` hcat rule is wrong for [I array] Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant