提交 1e91880d authored 作者: Arnaud Bergeron's avatar Arnaud Bergeron

Add a sample test for strided transfers.

上级 d95b7cd7
...@@ -203,11 +203,32 @@ def test_transfer_cpu_gpu(): ...@@ -203,11 +203,32 @@ def test_transfer_cpu_gpu():
f = theano.function([a], gpu_from_host(a)) f = theano.function([a], gpu_from_host(a))
fv = f(av) fv = f(av)
assert GpuArrayType.values_eq_approx(fv, gv) assert GpuArrayType.values_eq(fv, gv)
f = theano.function([g], host_from_gpu(g))
fv = f(gv)
assert numpy.all(fv == av)
def test_transfer_strided():
# This is just to ensure that it works in theano
# compyte has a much more comprehensive suit of tests to ensure correctness
a = T.fmatrix('a')
g = GpuArrayType(dtype='float32', broadcastable=(False, False))('g')
av = numpy.asarray(rng.rand(5, 8), dtype='float32')
gv = gpuarray.array(av)
av = av[:,::2]
gv = gv[:,::2]
f = theano.function([a], gpu_from_host(a))
fv = f(av)
assert GpuArrayType.values_eq(fv, gv)
f = theano.function([g], host_from_gpu(g)) f = theano.function([g], host_from_gpu(g))
fv = f(gv) fv = f(gv)
assert numpy.allclose(fv, av) assert numpy.all(fv == av)
def test_transfer_cuda_gpu(): def test_transfer_cuda_gpu():
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论