提交 5718f0b7 authored 作者: Frederic Bastien's avatar Frederic Bastien

Don't move complex to the GPU in the new back-end.

上级 9f759f07
...@@ -574,6 +574,8 @@ class GpuFromHost(Op): ...@@ -574,6 +574,8 @@ class GpuFromHost(Op):
def make_node(self, x): def make_node(self, x):
if not isinstance(x.type, tensor.TensorType): if not isinstance(x.type, tensor.TensorType):
raise TypeError(x) raise TypeError(x)
if "complex" in x.dtype:
raise TypeError("complex not supported in the new gpuarray back-end.", x)
return Apply(self, [x], [GpuArrayType(broadcastable=x.broadcastable, return Apply(self, [x], [GpuArrayType(broadcastable=x.broadcastable,
context_name=self.context_name, context_name=self.context_name,
dtype=x.dtype)()]) dtype=x.dtype)()])
......
...@@ -191,8 +191,9 @@ def op_lifter(OP, cuda_only=False): ...@@ -191,8 +191,9 @@ def op_lifter(OP, cuda_only=False):
# Check if we should replace # Check if we should replace
if (not replace or if (not replace or
(cuda_only and (cuda_only and
get_context(context_name).kind != b'cuda')): get_context(context_name).kind != b'cuda') or
any(["complex" in i.dtype for i in node.inputs])):
return False return False
# tag the inputs with the context in case # tag the inputs with the context in case
...@@ -298,7 +299,8 @@ class GraphToGPU(Optimizer): ...@@ -298,7 +299,8 @@ class GraphToGPU(Optimizer):
for i in fgraph.inputs: for i in fgraph.inputs:
# Do not move *int* scalar to the GPU. # Do not move *int* scalar to the GPU.
if (isinstance(i.type, tensor.TensorType) and if (isinstance(i.type, tensor.TensorType) and
(i.ndim > 0 or 'int' not in i.dtype)): (i.ndim > 0 or 'int' not in i.dtype) and
"complex" not in i.dtype):
mapping[i] = i.transfer(getattr(i.tag, 'target', target)) mapping[i] = i.transfer(getattr(i.tag, 'target', target))
else: else:
mapping[i] = i mapping[i] = i
...@@ -344,6 +346,9 @@ class GraphToGPU(Optimizer): ...@@ -344,6 +346,9 @@ class GraphToGPU(Optimizer):
self.local_optimizers_map.get(type(c.op), []))): self.local_optimizers_map.get(type(c.op), []))):
move_to_GPU = True move_to_GPU = True
new_ops = None new_ops = None
if move_to_GPU and any(["complex" in i.dtype for i in node.inputs]):
move_to_GPU = False
# Apply the lifter # Apply the lifter
if move_to_GPU: if move_to_GPU:
for lopt in (self.local_optimizers_map.get(node.op, []) + for lopt in (self.local_optimizers_map.get(node.op, []) +
......
...@@ -472,3 +472,12 @@ def test_local_assert_no_cpu_op(): ...@@ -472,3 +472,12 @@ def test_local_assert_no_cpu_op():
theano.function([], out, mode=mode_local_assert) theano.function([], out, mode=mode_local_assert)
finally: finally:
theano.config.assert_no_cpu_op = old theano.config.assert_no_cpu_op = old
def test_no_complex():
width_var = tensor.cscalar()
freq_var = tensor.fscalar()
signal_var = tensor.fscalar()
stft_out = tensor.exp(width_var * freq_var) * signal_var
theano.function([width_var, freq_var, signal_var], stft_out,
mode=mode_with_gpu)
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论