提交 0e8e5009 authored 作者: Li's avatar Li 提交者: Frederic

not ready, work on it later

上级 640f8956
...@@ -1069,7 +1069,8 @@ class FunctionMaker(object): ...@@ -1069,7 +1069,8 @@ class FunctionMaker(object):
gof.Op.add_stack_trace_on_call = False gof.Op.add_stack_trace_on_call = False
start_optimizer = time.time() start_optimizer = time.time()
import ipdb; ipdb.set_trace() import ipdb; ipdb.set_trace()
optimizer_profile = optimizer(fgraph) is_same_graph(old_graph, fgraph.outputs, givens=...)
optimizer_profile = optimizer(fgraph)#fgraph.inputs, fgraph.outputs
end_optimizer = time.time() end_optimizer = time.time()
opt_time = end_optimizer - start_optimizer opt_time = end_optimizer - start_optimizer
if profile: if profile:
......
...@@ -2,16 +2,17 @@ import unittest ...@@ -2,16 +2,17 @@ import unittest
import theano import theano
import theano.tensor as T import theano.tensor as T
from theano.gof.graph import is_same_graph from theano.gof.graph import is_same_graph
from theano.gof import FunctionGraph
from theano.scan_module.scan_utils import equal_computations from theano.scan_module.scan_utils import equal_computations
def graphs_equal(x, y): def graphs_equal(x, y):
# check if two graphs are equal # check if two graphs are equal
# x: outputs list of graph A # x: outputs list of graph A
# y: outputs list of graph B # y: outputs list of graph B
import ipdb; ipdb.set_trace()
while True: pass
pass
def test_graph_equivalence(): def test_graph_equivalence():
# Test if equivalent graphs are in fact equivalent # Test if equivalent graphs are in fact equivalent
# by using some functions in Theano # by using some functions in Theano
...@@ -34,7 +35,11 @@ def test_graph_equivalence(): ...@@ -34,7 +35,11 @@ def test_graph_equivalence():
assert is_same_graph(g1_y, g1_y) assert is_same_graph(g1_y, g1_y)
assert is_same_graph(g1_y, g1_yy) assert is_same_graph(g1_y, g1_yy)
assert is_same_graph(g1_y, g3_y, givens={g1_a: g3_a, g1_b: g3_b}) assert is_same_graph(g1_y, g3_y, givens={g1_a: g3_a, g1_b: g3_b})
FunctionGraph([], g1_y) l1=theano.gof.graph.inputs(g1_y)
l2=theano.gof.graph.inputs(g3_y)
assert len(l1) == len(l2)
#FunctionGraph([], g1_y)
#assert graphs_equal(g1_y, g3_y) == True #assert graphs_equal(g1_y, g3_y) == True
#assert graphs_equal(g1_y, g2_y) == False #assert graphs_equal(g1_y, g2_y) == False
...@@ -48,4 +53,4 @@ def test_graph_optimization_caching(): ...@@ -48,4 +53,4 @@ def test_graph_optimization_caching():
if __name__ == '__main__': if __name__ == '__main__':
#test_graph_optimization_caching() #test_graph_optimization_caching()
test_graph_equivalence() test_graph_equivalence()
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论