Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some gradient errors #66

Closed
mcabbott opened this issue Jan 28, 2019 · 3 comments
Closed

Some gradient errors #66

mcabbott opened this issue Jan 28, 2019 · 3 comments

Comments

@mcabbott
Copy link
Member

I had a go at using Zygote on something, and got some errors, which survive in the following simplified examples:

using Flux, Zygote

function ff(x, t = [1,2,3])  
    a = dropdims(sum( x .^ t' , dims=1), dims=1)
    sum(x)
end

Flux.gradient(ff, ones(3))
Zygote.gradient(ff, ones(3)) # ERROR: Compiling Tuple{typeof(in),Int64,Tuple{Int64}}: BoundsError: attempt to access 56-element Array{Any,1} at index [84]

and

function hh(x)  
    a = sum( x .^ [1 2 3] , dims=1)
    sum(x)
end

Flux.gradient(hh, ones(3))
Zygote.gradient(hh, ones(3)) # ERROR: UndefVarError: T not defined

I also got the same error as #47, but only when using a custom type; could try to boil that down if it would be helpful.

All on master of today, and Julia 1.1.

@MikeInnes
Copy link
Member

On Julia master I get

julia> function ff(x, t = [1,2,3])
           a = dropdims(sum( x .^ t' , dims=1), dims=1)
           sum(x)
       end
ff (generic function with 2 methods)

julia> ff(ones(3))
3.0

julia> gradient(ff, ones(3))
(Int8[1, 1, 1],)

julia> function hh(x)
           a = sum( x .^ [1 2 3] , dims=1)
           sum(x)
       end
hh (generic function with 1 method)

julia> gradient(hh, ones(3))
ERROR: Mutating arrays is not supported

Closing this as fixed since the compiler errors are gone; of course the second example should work ideally, but that's just a case of #81.

@mcabbott
Copy link
Member Author

Thanks, sounds good. I have one more case which boils down to the following:

julia> using Zygote

julia> y, back = Zygote._forward((m,v) -> (v .+ v' .+ m)[1,1], rand(3,3), rand(3))
(1.7873601043525784, (getfield(Main, Symbol("##43#44"))()))

julia> back(0.666)
ERROR: BoundsError: attempt to access 0-element Array{Core.Compiler.BasicBlock,1} at index [1]
Stacktrace:
 [1] getindex at ./array.jl:729 [inlined]
 [2] iterate(::Core.Compiler.IncrementalCompact, ::Tuple{Int64,Int64}) at ./compiler/ssair/ir.jl:1077
 [3] iterate at ./compiler/ssair/ir.jl:1070 [inlined]

@MikeInnes
Copy link
Member

Yup, you found another compiler bug there. Will reopen in that case. (You are also free to open new issues for new errors though).

@MikeInnes MikeInnes reopened this Mar 10, 2019
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

No branches or pull requests

2 participants