提交 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,
def init_dev(dev):
import globals
if dev.startswith('cuda'):
# format is cuda<devnum>
globals.kind = 'cuda'
devnum = int(dev[4:])
elif dev.startswith('opencl'):
# format is opencl<platnum>:<devnum>
globals.kind = 'opencl'
devspec = dev[7:]
devspec = dev[6:]
plat, dev = devspec.split(':')
devnum = int(dev)|(int(plat)<<16)
else:
......@@ -51,7 +53,7 @@ if pygpu:
if (config.device.startswith('cuda') or
config.device.startswith('opencl')):
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
theano.compile.shared_constructor(gpuarray_shared_constructor)
elif config.gpuarray.init_device != '':
......
......@@ -15,7 +15,7 @@ from type import GpuArrayType
def as_gpuarray_variable(x):
if hasattr(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)
return gpu_from_host(tensor_x)
......
......@@ -61,14 +61,14 @@ class GpuArrayType(Type):
kind=self.kind, context=self.context,
ndmin=len(self.broadcastable))
else:
if isinstance(data, gpuarray.GpuArray):
up_dtype = scalar.upcast(self.dtype, data.dtype)
if up_dtype == self.dtype:
data = data.astype(self.dtype)
else:
raise TypeError("%s cannot store a value of dtype %s "
"without risking loss of precision." %
(self, data.dtype))
up_dtype = scalar.upcast(self.dtype, data.dtype)
if up_dtype == self.dtype:
data = gpuarray.array(data, dtype=self.typecode, copy=False,
kind=self.kind, context=self.context)
else:
raise TypeError("%s cannot store a value of dtype %s "
"without risking loss of precision." %
(self, data.dtype))
if self.ndim != data.ndim:
raise TypeError("Wrong number of dimensions: expected %s, "
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论