store graphs

This commit is contained in:
Mike J Innes 2017-10-09 09:15:59 +01:00
parent e9c781cd10
commit 194bf6d3fb
2 changed files with 15 additions and 2 deletions

View File

@ -4,7 +4,7 @@ module Flux
# Zero Flux Given
using Juno, Requires
using Juno, Requires, DataFlow
using MacroTools: @forward
export Chain, Dense, RNN, LSTM,

View File

@ -1,11 +1,24 @@
module Graph
using DataFlow, MacroTools
using DataFlow: graphm, il, constructor, mapconst
export @net
graph(x) = nothing
function graphdef(m, T, args, body)
v = il(graphm(body, args = args)) |> DataFlow.striplines
:(Graph.graph($(esc(m))::$(esc(T))) = $(constructor(mapconst(esc, v))))
end
macro net(ex)
esc(ex)
@capture(shortdef(ex), (m_::T_)(args__) = body_) ||
error("@net requires a forward pass")
quote
$(esc(ex))
$(graphdef(m, T, args, body))
end
end
end