提交 83c76420 authored 作者: Razvan Pascanu's avatar Razvan Pascanu

make sure that in speed tests for RNN everything runs with CVM.

I wanted to make sure that I get the right timings. It seems that CVM is faster then what James suggested for now on CPU, and slower on GPU(but can be fixed). Note that a full implementation of what James suggested will be slower then what this text predicts ( this is as fast as it will ever get ), namely scan needs to do a bit more bookeeping that the cython right now does.
上级 1f00a3ca
...@@ -2460,7 +2460,8 @@ def test_speed(): ...@@ -2460,7 +2460,8 @@ def test_speed():
s_r = tensor.matrix() s_r = tensor.matrix()
s_y, updates = theano.scan(fn=lambda ri, rii:ri+rii, s_y, updates = theano.scan(fn=lambda ri, rii:ri+rii,
sequences=[s_r[1:]], sequences=[s_r[1:]],
outputs_info=tensor.constant(r[0])) outputs_info=tensor.constant(r[0]),
mode = theano.Mode(linker='cvm') )
assert not updates assert not updates
f = theano.function([s_r], s_y) f = theano.function([s_r], s_y)
...@@ -2530,9 +2531,10 @@ def test_speed_rnn(): ...@@ -2530,9 +2531,10 @@ def test_speed_rnn():
s_r = tensor.matrix() s_r = tensor.matrix()
s_y, updates = theano.scan(fn=lambda ri, rii:tensor.tanh(tensor.dot(rii, w)), s_y, updates = theano.scan(fn=lambda ri, rii:tensor.tanh(tensor.dot(rii, w)),
sequences=[s_r[1:]], sequences=[s_r[1:]],
outputs_info=tensor.constant(r[0])) outputs_info=tensor.constant(r[0]),
mode = theano.Mode(linker='cvm'))
assert not updates assert not updates
f = theano.function([s_r], s_y, mode=theano.Mode(linker='c|py_nogc')) f = theano.function([s_r], s_y, mode=theano.Mode(linker='cvm'))
t2 = time.time() t2 = time.time()
f(r) f(r)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论