more intuitive naming

This commit is contained in:
Mike J Innes 2017-02-21 08:56:05 +00:00
parent 4fb51d1752
commit 521258eb08
2 changed files with 5 additions and 5 deletions

View File

@ -69,17 +69,17 @@ 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, @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.") DataFlow.iscyclic(g) && error("This model has a cycle; try unrolling it first.")
interpret(ctx, g, args...) interpret(ctx, g, args...)
end end
graph(ctx::Context, args...) = @ithrow ctx graph(ctx, args...) graph(ctx::Context, args...) = @icatch ctx graph(ctx, args...)
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 = @icatch graph(ctx, model, args...) out = @ithrow graph(ctx, model, args...)
return ctx[:params], ctx[:stacks], out return ctx[:params], ctx[:stacks], out
end end

View File

@ -27,7 +27,7 @@ imap(f, args...) = f(args...)
function interp(ctx, f, xs...) function interp(ctx, f, xs...)
g = graph(f) g = graph(f)
@ithrow(ctx, g nothing ? @icatch(ctx, g nothing ?
interpret(ctx, reifyparams(g), xs...) : interpret(ctx, reifyparams(g), xs...) :
f(xs...)) f(xs...))
end end
@ -36,7 +36,7 @@ end
function interpmodel(m, args::Batch...) function interpmodel(m, args::Batch...)
ctx = Context(mux(iline, ilambda, iconst, iargs, ituple, interp)) 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 end
interpmodel(m, args...) = unbatchone(interpmodel(m, batchone(args)...)) interpmodel(m, args...) = unbatchone(interpmodel(m, batchone(args)...))