JuliaDiff / JuliaDiff/Diffractor.jl
no method matching setindex!(::ChainRulesCore.NoTangent, ::Float64, ::Int64)
Open
Nobody has claimed this yet.
bug
forward-mode
mutation
- Dominant language
- Julia
- Stars
- 453
- Forks
- 33
- PR merge metrics
- No merged PRs in 30d
Description
Simple example of taking the jacobian of the identity function, but the identity function allocates a new vector and assigns by iteration:
function identity_loop(x)
y = similar(x)
for i in eachindex(x, y)
y[i] = x[i]
end
return y
end
julia> AD.jacobian(Diffractor.DiffractorForwardBackend(), identity_loop, rand(2))
ERROR: MethodError: no method matching setindex!(::ChainRulesCore.NoTangent, ::Float64, ::Int64)
Stacktrace:
[1] frule(::Tuple{…}, ::typeof(setindex!), x::Vector{…}, v::Float64, inds::Int64)
@ ChainRules ~/.julia/packages/ChainRules/9sNmB/src/rulesets/Base/indexing.jl:215
[2] (::Diffractor.∂☆internal{1})(::ZeroBundle{1, typeof(setindex!)}, ::Vararg{Diffractor.AbstractTangentBundle{1}})
@ Diffractor ~/.julia/packages/Diffractor/QyO8B/src/stage1/forward.jl:119
[3] (::Diffractor.∂☆{1})(::ZeroBundle{1, typeof(setindex!)}, ::Vararg{Diffractor.AbstractTangentBundle{1}})
@ Diffractor ~/.julia/packages/Diffractor/QyO8B/src/stage1/forward.jl:160
[4] identity_loop
@ Diffractor ./REPL[11]:4 [inlined]
[5] (::Diffractor.∂☆recurse{…})(::ZeroBundle{…}, ::Diffractor.TangentBundle{…})
@ Diffractor ~/.julia/packages/Diffractor/QyO8B/src/stage1/recurse_fwd.jl:0
[6] (::Diffractor.∂☆internal{1})(::ZeroBundle{1, typeof(identity_loop)}, ::Vararg{Diffractor.AbstractTangentBundle{1}})
@ Diffractor ~/.julia/packages/Diffractor/QyO8B/src/stage1/forward.jl:121
[7] (::Diffractor.∂☆{1})(::ZeroBundle{1, typeof(identity_loop)}, ::Vararg{Diffractor.AbstractTangentBundle{1}})
@ Diffractor ~/.julia/packages/Diffractor/QyO8B/src/stage1/forward.jl:160
[8] (::Diffractor.var"#pushforward#359")(vs::Any)
@ Diffractor ~/.julia/packages/Diffractor/QyO8B/src/AbstractDifferentiation.jl:13 [inlined]
[9] (::Diffractor.var"#358#362")(cols::Any)
@ Diffractor ~/.julia/packages/AbstractDifferentiation/eEkWP/src/AbstractDifferentiation.jl:526 [inlined]
[10] mapslices(f::Diffractor.var"#358#362"{Diffractor.var"#pushforward#359"{…}}, A::Matrix{Float64}; dims::Int64)
@ Base ./abstractarray.jl:3179
[11] jacobian(b::Diffractor.DiffractorForwardBackend, f::Function, args::Vector{Float64})
@ Diffractor ~/.julia/packages/AbstractDifferentiation/eEkWP/src/AbstractDifferentiation.jl:524
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
Reproduce the failure with identity_loop and AD.jacobian, then start by reading ChainRules' indexing.jl at the setindex! rule and Diffractor's stage1/forward.jl entries shown in the stack trace. Trace how the NoTangent value reaches setindex! and verify the identity-loop Jacobian example completes without the reported MethodError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100