use iargs
This commit is contained in:
parent
ce04a9f3c1
commit
a73b53e05e
@ -8,7 +8,7 @@ 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, stack, mux
|
interpv, ituple, ilambda, iconst, iline, iargs, stack, mux
|
||||||
using Flux: imap
|
using Flux: imap
|
||||||
|
|
||||||
# TODO: implement Julia's type promotion rules
|
# TODO: implement Julia's type promotion rules
|
||||||
@ -61,7 +61,7 @@ end
|
|||||||
interp(ctx, p::Constant) = node(p.value)
|
interp(ctx, p::Constant) = node(p.value)
|
||||||
|
|
||||||
function graph(ctx::Context, model, args...)
|
function graph(ctx::Context, model, args...)
|
||||||
node = graph(model, interpv(ctx, args)...)
|
node = graph(model, args...)
|
||||||
isa(node, mx.SymbolicNode) && (ctx[:stacks][nodename(node)] = stack(ctx))
|
isa(node, mx.SymbolicNode) && (ctx[:stacks][nodename(node)] = stack(ctx))
|
||||||
return node
|
return node
|
||||||
end
|
end
|
||||||
@ -70,11 +70,11 @@ function interp(ctx, model, args...)
|
|||||||
g = Flux.graph(model)
|
g = Flux.graph(model)
|
||||||
g == nothing && return graph(ctx, model, args...)
|
g == nothing && return graph(ctx, 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, interpv(ctx, args)...)
|
interpret(ctx, g, args...)
|
||||||
end
|
end
|
||||||
|
|
||||||
function tograph(model, args...)
|
function tograph(model, args...)
|
||||||
ctx = Context(mux(iline, ilambda, ituple, imap, interp),
|
ctx = Context(mux(iline, ilambda, imap, iargs, interp),
|
||||||
params = Dict(), stacks = Dict())
|
params = Dict(), stacks = Dict())
|
||||||
out = interp(ctx, model, map(constant, args)...)
|
out = interp(ctx, model, map(constant, args)...)
|
||||||
return ctx[:params], ctx[:stacks], out
|
return ctx[:params], ctx[:stacks], out
|
||||||
|
Loading…
Reference in New Issue
Block a user