JuliaDiff / JuliaDiff/ChainRules.jl
`hcat` rule is wrong for `[I array]`
Open
Nobody has claimed this yet.
bug
- Dominant language
- Julia
- Stars
- 475
- Forks
- 98
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the rrule(hcat, I, 11:13) example in the issue and inspect the hcat rule introduced in #614. The fix is complete when the rule handles the size inferred for [I array] correctly and returns the expected tangents for the displayed input.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100