提交 c1b2c1b6 authored 作者: Frederic's avatar Frederic

Added comment following code review.

上级 38f3f8c5
...@@ -249,6 +249,9 @@ Here is some code that test the optimization is applied only when needed. ...@@ -249,6 +249,9 @@ Here is some code that test the optimization is applied only when needed.
x = T.dvector() x = T.dvector()
f = function([x], fibby(x)) f = function([x], fibby(x))
#theano.printing.debugprint(f) #theano.printing.debugprint(f)
#We call the function to make sure it run.
#If you run in DebugMode, it will compare the C and Python output
f(numpy.random.rand(5)) f(numpy.random.rand(5))
topo = f.maker.fgraph.toposort() topo = f.maker.fgraph.toposort()
assert len(topo) == 1 assert len(topo) == 1
...@@ -257,7 +260,15 @@ Here is some code that test the optimization is applied only when needed. ...@@ -257,7 +260,15 @@ Here is some code that test the optimization is applied only when needed.
# Test that the optimization get applied # Test that the optimization get applied
f_zero = function([], fibby(T.zeros([5]))) f_zero = function([], fibby(T.zeros([5])))
#theano.printing.debugprint(f_zero) #theano.printing.debugprint(f_zero)
#If you run in DebugMode, it will compare the output before
# and after the optimization
f_zero() f_zero()
#Check that the optimization remove the Fibby Op.
#For security, the Theano memory interface make that the output
#of the function is always memory not aliaced to the input.
#That is why there is a DeepCopyOp op.
topo = f_zero.maker.fgraph.toposort() topo = f_zero.maker.fgraph.toposort()
assert len(topo) == 1 assert len(topo) == 1
assert isinstance(topo[0].op, theano.compile.ops.DeepCopyOp) assert isinstance(topo[0].op, theano.compile.ops.DeepCopyOp)
...@@ -954,6 +954,9 @@ class T_fibby(unittest.TestCase): ...@@ -954,6 +954,9 @@ class T_fibby(unittest.TestCase):
x = T.dvector() x = T.dvector()
f = function([x], fibby(x)) f = function([x], fibby(x))
#theano.printing.debugprint(f) #theano.printing.debugprint(f)
#We call the function to make sure it run.
#If you run in DebugMode, it will compare the C and Python output
f(numpy.random.rand(5)) f(numpy.random.rand(5))
topo = f.maker.fgraph.toposort() topo = f.maker.fgraph.toposort()
assert len(topo) == 1 assert len(topo) == 1
...@@ -962,7 +965,15 @@ class T_fibby(unittest.TestCase): ...@@ -962,7 +965,15 @@ class T_fibby(unittest.TestCase):
# Test that the optimization get applied # Test that the optimization get applied
f_zero = function([], fibby(T.zeros([5]))) f_zero = function([], fibby(T.zeros([5])))
#theano.printing.debugprint(f_zero) #theano.printing.debugprint(f_zero)
#If you run in DebugMode, it will compare the output before
# and after the optimization
f_zero() f_zero()
#Check that the optimization remove the Fibby Op.
#For security, the Theano memory interface make that the output
#of the function is always memory not aliaced to the input.
#That is why there is a DeepCopyOp op.
topo = f_zero.maker.fgraph.toposort() topo = f_zero.maker.fgraph.toposort()
assert len(topo) == 1 assert len(topo) == 1
assert isinstance(topo[0].op, theano.compile.ops.DeepCopyOp) assert isinstance(topo[0].op, theano.compile.ops.DeepCopyOp)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论