We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b1922a0 commit cc61d10Copy full SHA for cc61d10
test_theano.py
@@ -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