-
Notifications
You must be signed in to change notification settings - Fork 11
Closed
Description
julia> using JuliaInterpreter, Zygote, CodeTracking
julia> l, back = Zygote.forward(x -> sum(x), ones(10,10,10))
(1000.0, getfield(Zygote, Symbol("##71#72")){typeof(∂(getfield(Main, Symbol("##5#6"))()))}(∂(getfield(Main, Symbol("##5#6"))())))
julia> frame = JuliaInterpreter.enter_call(back, 1f0);
julia> frame, pc = JuliaInterpreter.debug_command(frame, :si);
julia> frame, pc = JuliaInterpreter.debug_command(frame, :si);
julia> frame, pc = JuliaInterpreter.debug_command(frame, :si);
julia> m = frame.framecode.scope; # showing this will crash Julia due to https://github.com/FluxML/Zygote.jl/issues/134
julia> m.name
:Pullback
julia> CodeTracking.definition(String, m)
ERROR: Base.Meta.ParseError("unexpected \"end\"")
Stacktrace:
[1] #parse#1(::Bool, ::Bool, ::Bool, ::Function, ::String, ::Int64) at .\meta.jl:129
[2] parse(::String, ::Int64) at .\meta.jl:121
[3] definition(::Type{String}, ::Method) at C:\Users\Kristoffer\Debugging\Debugger\dev\CodeTracking\src\CodeTracking.jl:209
[4] top-level scope at none:0src is at this point equal to
ignore(T) = all(T -> T <: Type, T.parameters)
@generated function _forward(ctx::Context, f, args...)
T = Tuple{f,args...}
ignore(T) && return :(f(args...), Pullback{$T}(()))
g = try _lookup_grad(T) catch e e end
!(g isa Tuple) && return :(f(args...), Pullback{$T}((f,)))
meta, forw, _ = g
argnames!(meta, Symbol("#self#"), :ctx, :f, :args)
forw = varargs!(meta, forw, 3)
forw = slots!(pis!(inlineable!(forw)))
return IRTools.update!(meta, forw)
end
@generated function (j::Pullback{T})(Δ) where T
ignore(T) && return :nothing
g = try _lookup_grad(T)
catch e
rethrow(CompileError(T,e))
end
if g == nothing
Δ == Nothing && return :nothing
return :(error("Non-differentiable function $(j.t[1])"))
end
meta, _, back = g
resize!(back.argtypes, 2)
argnames!(meta, Symbol("#self#"), :Δ)
back = slots!(inlineable!(back))
return IRTools.update!(meta, back)
endwith istart = 477 and then:
julia> print(s[477:end])
end
@generated function (j::Pullback{T})(Δ) where T
ignore(T) && return :nothing
g = try _
...starts with an end.
Metadata
Metadata
Assignees
Labels
No labels