提交 c12c9d69 authored 作者: Arnaud Bergeron's avatar Arnaud Bergeron

Add basic test for GpuAllocEmpty

上级 e971d93b
......@@ -40,6 +40,7 @@ from ..type import (GpuArrayType,
from ..basic_ops import (
host_from_gpu, gpu_from_host,
gpu_alloc, GpuAlloc,
GpuAllocEmpty,
gpu_from_cuda,
cuda_from_gpu, HostFromGpu,
GpuContiguous,
......@@ -309,6 +310,25 @@ class TestAlloc(test_basic.TestAlloc):
allocs = [GpuAlloc(), GpuAlloc(), T.Alloc()]
def test_alloc_empty():
for dt in ['float32', 'int8']:
f = theano.function([], GpuAllocEmpty(dt)(2, 3))
assert len(f.maker.fgraph.apply_nodes) == 1
out = f()
assert out.shape == (2, 3)
assert out.dtype == dt
f = theano.function([], [GpuAllocEmpty('uint64')(3, 2),
GpuAllocEmpty('uint64')(3, 2)])
out = f()
assert out[0].shape == (3, 2)
assert out[0].dtype == 'uint64'
assert out[1].shape == (3, 2)
assert out[1].dtype == 'uint64'
assert len([node for node in f.maker.fgraph.apply_nodes
if isinstance(node.op, GpuAllocEmpty)]) == 1
def test_shape():
x = GpuArrayType(dtype='float32', broadcastable=[False, False, False])()
v = gpuarray.zeros((3, 4, 5), dtype='float32')
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论