more intuitive naming
This commit is contained in:
parent
4fb51d1752
commit
521258eb08
@ -69,17 +69,17 @@ graph(ctx::Context, p::Constant) = node(p.value)
|
||||
|
||||
function graph(ctx::Context, model, args...)
|
||||
g = Flux.graph(model)
|
||||
g == nothing && return register(ctx, @ithrow ctx graph(model, args...))
|
||||
g == nothing && return register(ctx, @icatch ctx graph(model, args...))
|
||||
DataFlow.iscyclic(g) && error("This model has a cycle; try unrolling it first.")
|
||||
interpret(ctx, g, args...)
|
||||
end
|
||||
|
||||
graph′(ctx::Context, args...) = @ithrow ctx graph(ctx, args...)
|
||||
graph′(ctx::Context, args...) = @icatch ctx graph(ctx, args...)
|
||||
|
||||
function tograph(model, args...)
|
||||
ctx = Context(mux(iline, ilambda, imap, iargs, ituple, graph′),
|
||||
params = Dict(), stacks = Dict())
|
||||
out = @icatch graph(ctx, model, args...)
|
||||
out = @ithrow graph(ctx, model, args...)
|
||||
return ctx[:params], ctx[:stacks], out
|
||||
end
|
||||
|
||||
|
@ -27,7 +27,7 @@ imap(f, args...) = f(args...)
|
||||
|
||||
function interp(ctx, f, xs...)
|
||||
g = graph(f)
|
||||
@ithrow(ctx, g ≠ nothing ?
|
||||
@icatch(ctx, g ≠ nothing ?
|
||||
interpret(ctx, reifyparams(g), xs...) :
|
||||
f(xs...))
|
||||
end
|
||||
@ -36,7 +36,7 @@ end
|
||||
|
||||
function interpmodel(m, args::Batch...)
|
||||
ctx = Context(mux(iline, ilambda, iconst, iargs, ituple, interp))
|
||||
rebatch(@icatch interp(ctx, m, map(rawbatch, args)...))
|
||||
rebatch(@ithrow interp(ctx, m, map(rawbatch, args)...))
|
||||
end
|
||||
|
||||
interpmodel(m, args...) = unbatchone(interpmodel(m, batchone(args)...))
|
||||
|
Loading…
Reference in New Issue
Block a user