Skip to content

Conversation

@dlfivefifty
Copy link
Contributor

This should fix

julia> f = x -> qr(BandedMatrix(0 => fill(x,10), -1 => ones(9), 1 => ones(9))).R[1,1]
#3 (generic function with 1 method)

julia> f'(0.1)
ERROR: UndefVarError: xs not defined
Stacktrace:
  [1] (::Zygote.var"#442#443")(#unused#::Nothing)
    @ Zygote ~/.julia/packages/Zygote/TaBlo/src/lib/array.jl:79
  [2] (::Zygote.var"#2351#back#444"{Zygote.var"#442#443"})(Δ::Nothing)
    @ Zygote ~/.julia/packages/ZygoteRules/OjfTt/src/adjoint.jl:59
  [3] Pullback
    @ ./broadcast.jl:894 [inlined]
  [4] Pullback
    @ ./broadcast.jl:891 [inlined]
  [5] Pullback
    @ ./broadcast.jl:887 [inlined]
  [6] (::typeof((materialize!)))(Δ::Nothing)
    @ Zygote ~/.julia/packages/Zygote/TaBlo/src/compiler/interface2.jl:0
  [7] Pullback
    @ ~/.julia/packages/BandedMatrices/Gbqeq/src/generic/AbstractBandedMatrix.jl:135 [inlined]
  [8] (::typeof((triu!)))(Δ::Zygote.OneElement{Float64, 2, Tuple{Int64, Int64}, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}})
    @ Zygote ~/.julia/packages/Zygote/TaBlo/src/compiler/interface2.jl:0
  [9] Pullback
    @ ~/Projects/julia-1.6/usr/share/julia/stdlib/v1.6/LinearAlgebra/src/generic.jl:435 [inlined]
 [10] (::typeof((triu!)))(Δ::Zygote.OneElement{Float64, 2, Tuple{Int64, Int64}, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}})
    @ Zygote ~/.julia/packages/Zygote/TaBlo/src/compiler/interface2.jl:0
 [11] Pullback
    @ ~/Projects/julia-1.6/usr/share/julia/stdlib/v1.6/LinearAlgebra/src/qr.jl:425 [inlined]
 [12] (::typeof((getproperty)))(Δ::Zygote.OneElement{Float64, 2, Tuple{Int64, Int64}, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}})
    @ Zygote ~/.julia/packages/Zygote/TaBlo/src/compiler/interface2.jl:0
 [13] Pullback
    @ ~/.julia/packages/ZygoteRules/OjfTt/src/ZygoteRules.jl:11 [inlined]
 [14] Pullback
    @ ./REPL[7]:1 [inlined]
 [15] (::typeof((#3)))(Δ::Float64)
    @ Zygote ~/.julia/packages/Zygote/TaBlo/src/compiler/interface2.jl:0
 [16] (::Zygote.var"#46#47"{typeof((#3))})(Δ::Float64)
    @ Zygote ~/.julia/packages/Zygote/TaBlo/src/compiler/interface.jl:41
 [17] gradient(f::Function, args::Float64)
    @ Zygote ~/.julia/packages/Zygote/TaBlo/src/compiler/interface.jl:76
 [18] (::Zygote.var"#48#49"{var"#3#4"})(x::Float64)
    @ Zygote ~/.julia/packages/Zygote/TaBlo/src/compiler/interface.jl:79
 [19] top-level scope
    @ REPL[8]:1

@DhairyaLGandhi
Copy link
Member

Hi, thanks for the contribution!

Could you add a @test_throws with copyto! also?

@CarloLucibello
Copy link
Member

coincidentally I just ran in a similar issue, didn't notice this PR, and accidentally pushed the fix on master using the github interface, Sorry for that

@DhairyaLGandhi
Copy link
Member

ref f878cf7 which seems to have been committed already.

Copy link
Member

@mcabbott mcabbott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Sorry about the bug, this fix is a little nicer than the earlier commit.

@CarloLucibello CarloLucibello merged commit a2b065a into FluxML:master Jul 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants