def test_deep_copy(): a = rand_gpuarray(20, dtype='float32') g = GpuArrayType(dtype='float32', broadcastable=(False,))('g') f = theano.function([g], g) assert isinstance(f.maker.fgraph.toposort()[0].op, DeepCopyOp) res = f(a) assert GpuArrayType.values_eq(res, a)
def test_deep_copy(): a = rand_gpuarray(20, dtype='float32') g = GpuArrayType(dtype='float32', broadcastable=(False, ))('g') f = theano.function([g], g) assert isinstance(f.maker.fgraph.toposort()[0].op, DeepCopyOp) res = f(a) assert GpuArrayType.values_eq(res, a)
def test_transfer_cpu_gpu(): a = T.fmatrix('a') g = GpuArrayType(dtype='float32', broadcastable=(False, False))('g') av = numpy.asarray(rng.rand(5, 4), dtype='float32') gv = gpuarray.array(av) 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)) 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)) 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)) fv = f(gv) assert numpy.all(fv == av)