提交 87abce94 authored 作者: Frederic Bastien's avatar Frederic Bastien

allow to test with cpu and gpu.

上级 76884de2
...@@ -11,25 +11,28 @@ shapes=(2000,2000) ...@@ -11,25 +11,28 @@ shapes=(2000,2000)
iters = 10 iters = 10
a=T.matrix() a=theano.shared(numpy.ones(shapes, dtype=theano.config.floatX))
b=T.matrix() b=theano.shared(numpy.ones(shapes, dtype=theano.config.floatX))
c=theano.shared(numpy.ones(shapes, dtype=theano.config.floatX))
c=theano.shared(numpy.ones(shapes)) f=theano.function([],updates={c:0.4*c+.8*T.dot(a,b)})
f=theano.function([a,b],updates={c:0.4*c+.8*T.dot(a,b)})
print 'blas.ldflags=',theano.config.blas.ldflags print 'blas.ldflags=',theano.config.blas.ldflags
print 'compiledir=',theano.config.compiledir print 'compiledir=',theano.config.compiledir
if any( [x.op.__class__.__name__=='Gemm' for x in f.maker.env.toposort()]):
print 'Used the cpu'
elif any( [x.op.__class__.__name__=='GpuGemm' for x in f.maker.env.toposort()]):
print 'Used the gpu'
print f.maker.env.toposort() print f.maker.env.toposort()
av=numpy.ones(shapes)
bv=numpy.ones(shapes)
t0=time.time() t0=time.time()
for i in range(iters): for i in range(iters):
f(av,bv) f()
print
print 'times=%.2fs'%(time.time()-t0) print 'times=%.2fs'%(time.time()-t0)
print """ print """
Some result that you can compare again: Some result that you can compare again on the cpu:
Lib: goto Lib: goto
computer: Intel(R) Xeon(R) CPU E5430 @ 2.66GHz computer: Intel(R) Xeon(R) CPU E5430 @ 2.66GHz
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论