TuringLang / IRTracker.jl

Dynamically track IR as a graph, using source transformations
31 stars 5 forks source link

Update error functions #32

Closed phipsgabler closed 4 years ago

phipsgabler commented 4 years ago

Currently, error_ir does not even get the signature right (although id does error correctly). Replace it by something like

function error_ir(F, Args...)
    # create empty IR which matches the (non-existing) signature given by f(args)
    dummy(Args...) = nothing
    T = Tuple{AbstractTrackingContext, Core.Typeof(dummy), Core.Typeof.(Args)...}
    ir = IRTools.empty(IR(IRTools.meta(T)))
    self = IRTools.argument!(ir)
    ctx = IRTools.argument!(ir)
    arg_values = ntuple(_ -> IRTools.argument!(ir), length(Args))
    error_result = push!(ir, DCGCall.trackingerror(self, arg_values...))
    IRTools.return!(ir, error_result)
    return ir
end

(not yet working), and make trackingerror context-overloadable.

phipsgabler commented 4 years ago

Possibly better solution: don't use a dynamo anymore, and instead do as in https://github.com/FluxML/Zygote.jl/blob/master/src/compiler/interface2.jl.

Which would also facilitate getting the slot names out of IR.