JuliaDiff / JuliaDiff/ChainRules.jl
Rule for `foldl` fails on empty tuple
Open
Nobody has claimed this yet.
bug
- Dominant language
- Julia
- Stars
- 475
- Forks
- 98
- PR merge metrics
- No merged PRs in 30d
Description
Found here: https://github.com/FluxML/Zygote.jl/issues/1297
julia> using ChainRules, ChainRulesCore, ChainRulesTestUtils
julia> const CFG = ChainRulesTestUtils.TestConfig();
julia> foldl(/, (), init=0)
0
julia> rrule(CFG, foldl, /, (), init=0)
ERROR: BoundsError: attempt to access Tuple{} at index [0]
Stacktrace:
[1] getindex(t::Tuple, i::Int64)
@ Base ./tuple.jl:29
[2] last(a::Tuple{})
@ Base ./abstractarray.jl:500
[3] rrule(config::ChainRulesTestUtils.TestConfig, ::typeof(foldl), op::typeof(/), x::Tuple{}; init::Int64)
@ ChainRules ~/.julia/packages/ChainRules/fgVxV/src/rulesets/Base/mapreduce.jl:448
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
The failing entry point is the foldl rrule in src/rulesets/Base/mapreduce.jl around line 448. Reproduce the reported rrule(CFG, foldl, /, (), init=0) call first; done means the empty-tuple case no longer raises BoundsError and preserves foldl's result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 58/100