提交 4a825957 authored 作者: Frederic Bastien's avatar Frederic Bastien

fix test for HostFromGpu.infer_shape and GpuFromHost.infer_shape.

上级 f89e86ef
...@@ -445,25 +445,28 @@ def test_hostfromgpu_shape_i(): ...@@ -445,25 +445,28 @@ def test_hostfromgpu_shape_i():
m = mode_with_gpu.including('local_dot_to_dot22','local_dot22_to_dot22scalar','specialize') m = mode_with_gpu.including('local_dot_to_dot22','local_dot22_to_dot22scalar','specialize')
a=T.fmatrix('a') a=T.fmatrix('a')
b=T.fmatrix('b') ca=theano.sandbox.cuda.var.CudaNdarrayType((False,False))()
c=T.fmatrix('c')
ca=theano.sandbox.cuda.var.CudaNdarrayVariable((False,False)) av=numpy.asarray(numpy.random.rand(5,4),dtype='float32')
cb=theano.sandbox.cuda.var.CudaNdarrayVariable((False,False)) cv=cuda.CudaNdarray(numpy.asarray(numpy.random.rand(5,4),dtype='float32'))
cc=theano.sandbox.cuda.var.CudaNdarrayVariable((False,False))
av=numpy.asarray(numpy.random.rand(5,5),dtype='float32') f = theano.function([a],cuda.basic_ops.gpu_from_host(a))
bv=numpy.asarray(numpy.random.rand(5,5),dtype='float32') assert cuda.basic_ops.gpu_from_host in [x.op for x in f.maker.env.toposort()]
cv=numpy.asarray(numpy.random.rand(5,5),dtype='float32') f = theano.function([a],cuda.basic_ops.gpu_from_host(a).shape)
sa = theano.shared(av, name = 'sa')
sb = theano.shared(bv, name = 'sb')
f = theano.function([a,b],[(a+b).shape],mode=m)
topo = f.maker.env.toposort() topo = f.maker.env.toposort()
assert isinstance(topo[0].op,T.opt.Shape_i) assert isinstance(topo[0].op,T.opt.Shape_i)
assert isinstance(topo[1].op,T.opt.Shape_i) assert isinstance(topo[1].op,T.opt.Shape_i)
assert isinstance(topo[2].op,T.opt.MakeVector) assert isinstance(topo[2].op,T.opt.MakeVector)
assert tuple(f(av))==(5,4)
f2 = theano.function([],[(sa+sb).shape],mode=m)
topo = f2.maker.env.toposort() f = theano.function([ca],cuda.basic_ops.host_from_gpu(ca))
assert cuda.basic_ops.host_from_gpu in [x.op for x in f.maker.env.toposort()]
f = theano.function([ca],cuda.basic_ops.host_from_gpu(ca).shape)
topo = f.maker.env.toposort()
assert isinstance(topo[0].op,T.opt.Shape_i) assert isinstance(topo[0].op,T.opt.Shape_i)
assert isinstance(topo[1].op,T.opt.Shape_i) assert isinstance(topo[1].op,T.opt.Shape_i)
assert isinstance(topo[2].op,T.opt.MakeVector) assert isinstance(topo[2].op,T.opt.MakeVector)
assert tuple(f(cv))==(5,4)
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论