提交 8961ac2e authored 作者: Arnaud Bergeron's avatar Arnaud Bergeron

XXX -> TODO and fix GpuArrayType.filter logic.

上级 3f16fbc5
...@@ -34,11 +34,13 @@ from type import (GpuArrayType, GpuArrayVariable, GpuArrayConstant, ...@@ -34,11 +34,13 @@ from type import (GpuArrayType, GpuArrayVariable, GpuArrayConstant,
def init_dev(dev): def init_dev(dev):
import globals import globals
if dev.startswith('cuda'): if dev.startswith('cuda'):
# format is cuda<devnum>
globals.kind = 'cuda' globals.kind = 'cuda'
devnum = int(dev[4:]) devnum = int(dev[4:])
elif dev.startswith('opencl'): elif dev.startswith('opencl'):
# format is opencl<platnum>:<devnum>
globals.kind = 'opencl' globals.kind = 'opencl'
devspec = dev[7:] devspec = dev[6:]
plat, dev = devspec.split(':') plat, dev = devspec.split(':')
devnum = int(dev)|(int(plat)<<16) devnum = int(dev)|(int(plat)<<16)
else: else:
...@@ -51,7 +53,7 @@ if pygpu: ...@@ -51,7 +53,7 @@ if pygpu:
if (config.device.startswith('cuda') or if (config.device.startswith('cuda') or
config.device.startswith('opencl')): config.device.startswith('opencl')):
init_dev(config.device) init_dev(config.device)
# XXX add optimization tags here (when we will have some) # TODO add optimization tags here (when we will have some)
import theano.compile import theano.compile
theano.compile.shared_constructor(gpuarray_shared_constructor) theano.compile.shared_constructor(gpuarray_shared_constructor)
elif config.gpuarray.init_device != '': elif config.gpuarray.init_device != '':
......
...@@ -15,7 +15,7 @@ from type import GpuArrayType ...@@ -15,7 +15,7 @@ from type import GpuArrayType
def as_gpuarray_variable(x): def as_gpuarray_variable(x):
if hasattr(x, '_as_GpuArrayVariable'): if hasattr(x, '_as_GpuArrayVariable'):
return x._as_GpuArrayVariable() return x._as_GpuArrayVariable()
# XXX: we need to have the cuda -> gpu path taken care of. # TODO we need to have the cuda -> gpu path taken care of.
tensor_x = tensor.as_tensor_variable(x) tensor_x = tensor.as_tensor_variable(x)
return gpu_from_host(tensor_x) return gpu_from_host(tensor_x)
......
...@@ -61,14 +61,14 @@ class GpuArrayType(Type): ...@@ -61,14 +61,14 @@ class GpuArrayType(Type):
kind=self.kind, context=self.context, kind=self.kind, context=self.context,
ndmin=len(self.broadcastable)) ndmin=len(self.broadcastable))
else: else:
if isinstance(data, gpuarray.GpuArray): up_dtype = scalar.upcast(self.dtype, data.dtype)
up_dtype = scalar.upcast(self.dtype, data.dtype) if up_dtype == self.dtype:
if up_dtype == self.dtype: data = gpuarray.array(data, dtype=self.typecode, copy=False,
data = data.astype(self.dtype) kind=self.kind, context=self.context)
else: else:
raise TypeError("%s cannot store a value of dtype %s " raise TypeError("%s cannot store a value of dtype %s "
"without risking loss of precision." % "without risking loss of precision." %
(self, data.dtype)) (self, data.dtype))
if self.ndim != data.ndim: if self.ndim != data.ndim:
raise TypeError("Wrong number of dimensions: expected %s, " raise TypeError("Wrong number of dimensions: expected %s, "
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论