Roger-luo/YAAD.jl

Dynamic Graph Freezer: Freeze a dynamic graph to static graph

Opened this issue · 0 comments

We can use a macro for this, which will cancel dynamic computation graph generation and directly generate a static graph.

graph = @freeze begin
     x1, x2 = Variable(rand(10, 10)), Variable(rand(10, 10))
     y = sin.(x1 * x2)
     z = tr.(y)
end

forward propagation:

z = forward(graph)

backward propagation:

backward(graph, [grad])