JuliaDiff / JuliaDiff/Diffractor.jl

Splatting arrays

Open
#38 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
453
Forks
33
PR merge metrics
No merged PRs in 30d

Description

Diffractor doesn't seem to like array splats:

julia> gradient(x -> max(x...), (1,2,3))[1]
(0.0, 0.0, 1.0)

julia> gradient(x -> max(x...), [1,2,3])[1]
ERROR: MethodError: no method matching (::Diffractor.∂⃖recurse{1})(::typeof(Core._apply_iterate), ::typeof(iterate), ::typeof(max), ::Vector{Int64})
Closest candidates are:
  (::Diffractor.∂⃖recurse)(::Any...) at /Users/me/.julia/packages/Diffractor/2Ott3/src/stage1/generated.jl:398
Stacktrace:
  [1] macro expansion
    @ ~/.julia/packages/Diffractor/2Ott3/src/stage1/generated.jl:0 [inlined]
  [2] (::Diffractor.∂⃖recurse{1})(::typeof(Core._apply_iterate), ::typeof(iterate), ::typeof(max), ::Vector{Int64})
    @ Diffractor ~/.julia/packages/Diffractor/2Ott3/src/stage1/generated.jl:407
  [3] (::∂⃖{1})(::typeof(Core._apply_iterate), ::Function, ::Vararg{Any})
    @ Diffractor ~/.julia/packages/Diffractor/2Ott3/src/stage1/generated.jl:214
  [4] #9
    @ ./REPL[6]:1 [inlined]
  [5] (::Diffractor.∂⃖recurse{1})(::var"#9#10", ::Vector{Int64})
    @ Diffractor ~/.julia/packages/Diffractor/2Ott3/src/stage1/generated.jl:0
  [6] (::∂⃖{1})(f::var"#9#10", args::Vector{Int64})
    @ Diffractor ~/.julia/packages/Diffractor/2Ott3/src/stage1/generated.jl:214
  [7] ∂⃖(::Function, ::Vararg{Any})
    @ Diffractor ~/.julia/packages/Diffractor/2Ott3/src/interface.jl:25
  [8] (::Diffractor.∇{var"#9#10"})(args::Vector{Int64})
    @ Diffractor ~/.julia/packages/Diffractor/2Ott3/src/interface.jl:121
  [9] Diffractor.∇(::Function, ::Vector{Int64})
    @ Diffractor ~/.julia/packages/Diffractor/2Ott3/src/interface.jl:128

Zygote also gets this wrong: https://github.com/FluxML/Zygote.jl/issues/599

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the tuple and vector splat examples in the Julia REPL, then inspect the stage1/generated.jl stack-trace path and the entry points in interface.jl. Determine how array splats through Core._apply_iterate are handled compared with tuple splats. Done means the vector example returns the correct gradient and has a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.