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

Zygote fails with Char datatypes #69

Closed
staticfloat opened this issue Feb 2, 2019 · 0 comments
Closed

Zygote fails with Char datatypes #69

staticfloat opened this issue Feb 2, 2019 · 0 comments

Comments

@staticfloat
Copy link
Contributor

With the latest master of Zygote and IRTools:

struct Foo
    x
end

function (f::Foo)(x, mode)
    if mode == 'a'
        return x*f.x
    else
        return x/f.x
    end
end

xf, back = Zygote.forward(f -> f(1, 'a'), Foo(2.0))
back(1.0)

This results in:

ERROR: Compiling Tuple{getfield(Main, Symbol("##13#14")),Foo}: MethodError: no method matching exprtype(::Core.Compiler.IRCode, ::Char)
Closest candidates are:
  exprtype(::Core.Compiler.IRCode, ::Expr) at /Users/sabae/.julia/packages/Zygote/UFYYV/src/tools/ir.jl:64
  exprtype(::Core.Compiler.IRCode, ::QuoteNode) at /Users/sabae/.julia/packages/Zygote/UFYYV/src/tools/ir.jl:61
  exprtype(::Core.Compiler.IRCode, ::GlobalRef) at /Users/sabae/.julia/packages/Zygote/UFYYV/src/tools/ir.jl:60
  ...
Stacktrace:
 [1] _broadcast_getindex_evalf at ./broadcast.jl:582 [inlined]
 [2] _broadcast_getindex at ./broadcast.jl:555 [inlined]
 [3] getindex at ./broadcast.jl:515 [inlined]
 [4] copyto_nonleaf!(::Array{DataType,1}, ::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1},Tuple{Base.OneTo{Int64}},typeof(Zygote.exprtype),Tuple{Base.RefValue{Core.Compiler.IRCode},Base.Broadcast.Extruded{Array{Any,1},Tuple{Bool},Tuple{Int64}}}}, ::Base.OneTo{Int64}, ::Int64, ::Int64) at ./broadcast.jl:931
 [5] copy at ./broadcast.jl:794 [inlined]
 [6] materialize(::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1},Nothing,typeof(Zygote.exprtype),Tuple{Base.RefValue{Core.Compiler.IRCode},Array{Any,1}}}) at ./broadcast.jl:756
 [7] record!(::Core.Compiler.IRCode) at /Users/sabae/.julia/packages/Zygote/UFYYV/src/compiler/reverse.jl:151
 [8] #Primal#39(::Nothing, ::Type, ::Core.Compiler.IRCode) at /Users/sabae/.julia/packages/Zygote/UFYYV/src/compiler/reverse.jl:196
 [9] Type at ./none:0 [inlined]
 [10] #Adjoint#65 at /Users/sabae/.julia/packages/Zygote/UFYYV/src/compiler/reverse.jl:394 [inlined]
 [11] (::getfield(Core, Symbol("#kw#Type")))(::NamedTuple{(:varargs,),Tuple{Nothing}}, ::Type{Zygote.Adjoint}, ::Core.Compiler.IRCode) at ./none:0
 [12] _lookup_grad(::Type) at /Users/sabae/.julia/packages/Zygote/UFYYV/src/compiler/emit.jl:125
 [13] #s79#919 at /Users/sabae/.julia/packages/Zygote/UFYYV/src/compiler/interface2.jl:17 [inlined]
 [14] #s79#919(::Any, ::Any, ::Any) at ./none:0
 [15] (::Core.GeneratedFunctionStub)(::Any, ::Vararg{Any,N} where N) at ./boot.jl:506
 [16] (::getfield(Zygote, Symbol("##66#67")){Zygote.Pullback{Tuple{getfield(Main, Symbol("##13#14")),Foo},Tuple{getfield(Main, Symbol("##13#14"))}}})(::Float64) at /Users/sabae/.julia/packages/Zygote/UFYYV/src/compiler/interface.jl:38
 [17] top-level scope at none:0
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

1 participant