handle interpreter errors
This commit is contained in:
parent
62b1e7c411
commit
7750f5375b
@ -8,7 +8,8 @@ end
|
|||||||
|
|
||||||
using Base: @get!
|
using Base: @get!
|
||||||
using DataFlow: Constant, constant, Context, interpret, Split,
|
using DataFlow: Constant, constant, Context, interpret, Split,
|
||||||
interpv, ituple, ilambda, iconst, iline, iargs, stack, mux
|
interpv, ituple, ilambda, iconst, iline, iargs, stack, mux,
|
||||||
|
@ithrow, @icatch
|
||||||
using Flux: imap
|
using Flux: imap
|
||||||
|
|
||||||
# TODO: implement Julia's type promotion rules
|
# TODO: implement Julia's type promotion rules
|
||||||
@ -68,7 +69,7 @@ graph(ctx::Context, p::Constant) = node(p.value)
|
|||||||
|
|
||||||
function graph(ctx::Context, model, args...)
|
function graph(ctx::Context, model, args...)
|
||||||
g = Flux.graph(model)
|
g = Flux.graph(model)
|
||||||
g == nothing && return register(ctx, graph(model, args...))
|
g == nothing && return register(ctx, @ithrow ctx graph(model, args...))
|
||||||
DataFlow.iscyclic(g) && error("This model has a cycle; try unrolling it first.")
|
DataFlow.iscyclic(g) && error("This model has a cycle; try unrolling it first.")
|
||||||
interpret(ctx, g, args...)
|
interpret(ctx, g, args...)
|
||||||
end
|
end
|
||||||
@ -76,7 +77,7 @@ end
|
|||||||
function tograph(model, args...)
|
function tograph(model, args...)
|
||||||
ctx = Context(mux(iline, ilambda, imap, iargs, ituple, graph),
|
ctx = Context(mux(iline, ilambda, imap, iargs, ituple, graph),
|
||||||
params = Dict(), stacks = Dict())
|
params = Dict(), stacks = Dict())
|
||||||
out = graph(ctx, model, args...)
|
out = @icatch graph(ctx, model, args...)
|
||||||
return ctx[:params], ctx[:stacks], out
|
return ctx[:params], ctx[:stacks], out
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user