diff --git a/src/Flux.jl b/src/Flux.jl index 63e7350a..b86536b2 100644 --- a/src/Flux.jl +++ b/src/Flux.jl @@ -1,6 +1,6 @@ module Flux -using Lazy, Flow +using MacroTools, Lazy, Flow # Zero Flux Given diff --git a/src/rt/diff.jl b/src/rt/diff.jl index b23c747a..6f0615d6 100644 --- a/src/rt/diff.jl +++ b/src/rt/diff.jl @@ -22,3 +22,12 @@ function ∇graph(v::IVertex, ∇, out = d()) end return out end + +macro derive(ex) + v = vertex(Flow.Do()) + for (k, x) in ∇graph(il(graphm(resolve_calls(ex))), @flow(∇)) + k = Symbol("∇", k) + thread!(v, @v(Flow.Assign(k)(x))) + end + Expr(:quote, @> v cse syntax prettify) +end