Skip to content

Commit cc61d10

Browse files
author
danmcduff
committed
Adding Theano Test script
1 parent b1922a0 commit cc61d10

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

test_theano.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from theano import function, config, shared, sandbox
2+
import theano.tensor as T
3+
import numpy
4+
import time
5+
6+
vlen = 10 * 30 * 768 # 10 x #cores x # threads per core
7+
iters = 1000
8+
9+
rng = numpy.random.RandomState(22)
10+
x = shared(numpy.asarray(rng.rand(vlen), config.floatX))
11+
f = function([], T.exp(x))
12+
print f.maker.fgraph.toposort()
13+
t0 = time.time()
14+
for i in xrange(iters):
15+
r = f()
16+
t1 = time.time()
17+
print 'Looping %d times took' % iters, t1 - t0, 'seconds'
18+
print 'Result is', r
19+
if numpy.any([isinstance(x.op, T.Elemwise) for x in f.maker.fgraph.toposort()]):
20+
print 'Used the cpu'
21+
else:
22+
print 'Used the gpu'

0 commit comments

Comments
 (0)