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

Fixes so that test_opt.py passes.

上级 a9c0e1ac
......@@ -464,6 +464,7 @@ def local_gpu_pdbbreakpoint_op(node):
input_is_from_gpu = (inp.owner and
isinstance(inp.owner.op, HostFromGpu))
output_goes_to_gpu = False
for c in out.clients:
if c == 'output':
continue
......
......@@ -9,13 +9,12 @@ from theano.tensor.tests import test_basic
import theano.sandbox.gpuarray
from .. import basic_ops
from ..type import GpuArrayType, gpuarray_shared_constructor
from ..basic_ops import (GpuAlloc, GpuReshape, gpu_alloc,
gpu_from_host, host_from_gpu)
from ..type import GpuArrayType, gpuarray_shared_constructor, get_context
from ..basic_ops import GpuAlloc, GpuReshape, GpuFromHost, host_from_gpu
from ..elemwise import GpuCAReduceCuda, GpuCAReduceCPY, GpuElemwise
from ..subtensor import GpuSubtensor
from .config import mode_with_gpu, mode_without_gpu
from .config import mode_with_gpu, mode_without_gpu, test_ctx_name
from .test_basic_ops import rand_gpuarray
......@@ -99,7 +98,7 @@ def test_flatten():
def test_reduce():
dev = theano.sandbox.gpuarray.init_dev.device
kind = get_context(test_ctx_name).kind
for method, param in [('sum', dict(acc_dtype='float32')),
('prod', dict(acc_dtype='float32')),
......@@ -115,7 +114,7 @@ def test_reduce():
topo = f.maker.fgraph.toposort()
ops = [type(node.op) for node in topo]
if dev.startswith('opencl') and method in ["max", "min"]:
if kind == 'opencl' and method in ["max", "min"]:
assert not(GpuCAReduceCuda in ops or GpuCAReduceCPY in ops)
else:
assert GpuCAReduceCuda in ops or GpuCAReduceCPY in ops
......@@ -128,7 +127,7 @@ def test_local_gpualloc_memset_0():
ones = numpy.ones((2,), dtype='float32')
# Test with 0
a = gpu_alloc(z, i)
a = GpuAlloc(test_ctx_name)(z, i)
f = theano.function([i], a, mode=mode_with_gpu)
topo = f.maker.fgraph.toposort()
assert len(topo) == 1
......@@ -136,7 +135,7 @@ def test_local_gpualloc_memset_0():
assert (numpy.asarray(f(6)) == 0).all()
# Test with 1
a = gpu_alloc(o, i)
a = GpuAlloc(test_ctx_name)(o, i)
f = theano.function([i], a, mode=mode_with_gpu)
topo = f.maker.fgraph.toposort()
assert len(topo) == 1
......@@ -145,7 +144,7 @@ def test_local_gpualloc_memset_0():
assert (numpy.asarray(f(6)) == 1).all()
# Test with 1, 1
a = gpu_alloc(ones, i)
a = GpuAlloc(test_ctx_name)(ones, i)
f = theano.function([i], a, mode=mode_with_gpu)
topo = f.maker.fgraph.toposort()
assert len(topo) == 1
......@@ -182,7 +181,7 @@ def test_print_op():
f = theano.function([b], theano.printing.Print()(b) * 2,
mode=mode_with_gpu)
topo = f.maker.fgraph.toposort()
assert topo[0].op == gpu_from_host
assert isinstance(topo[0].op, GpuFromHost)
assert isinstance(topo[1].op, theano.printing.Print)
assert isinstance(topo[2].op, GpuElemwise)
assert topo[3].op == host_from_gpu
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论