提交 0ad41ce5 authored 作者: Arnaud Bergeron's avatar Arnaud Bergeron

Changes following review.

上级 fe2123da
...@@ -79,13 +79,13 @@ class DeviceParam(ConfigParam): ...@@ -79,13 +79,13 @@ class DeviceParam(ConfigParam):
else: else:
raise ValueError(('Invalid value ("%s") for configuration ' raise ValueError(('Invalid value ("%s") for configuration '
'variable "%s". Valid options start with ' 'variable "%s". Valid options start with '
'one of "gpu", "opencl", "cuda"' 'one of "%s", "gpu", "opencl", "cuda"'
% (val, self.fullname))) % (self.default, val, self.fullname)))
over = kwargs.get("allow_override", True) over = kwargs.get("allow_override", True)
super(DeviceParam, self).__init__(default, filter, over) super(DeviceParam, self).__init__(default, filter, over)
def __str__(self): def __str__(self):
return '%s (gpu*, opencl*, cuda*) ' % (self.fullname, self.default) return '%s (%s, gpu*, opencl*, cuda*) ' % (self.fullname, self.default)
AddConfigVar( AddConfigVar(
'device', 'device',
...@@ -208,6 +208,7 @@ AddConfigVar('dnn.conv.algo_bwd', ...@@ -208,6 +208,7 @@ AddConfigVar('dnn.conv.algo_bwd',
'time_on_shape_change'), 'time_on_shape_change'),
in_c_key=False) in_c_key=False)
def default_dnn_path(suffix): def default_dnn_path(suffix):
def f(suffix=suffix): def f(suffix=suffix):
if config.cuda.root == '': if config.cuda.root == '':
......
...@@ -536,6 +536,9 @@ def handle_shared_float32(tf): ...@@ -536,6 +536,9 @@ def handle_shared_float32(tf):
if config.device.startswith('gpu'): if config.device.startswith('gpu'):
use(device=config.device, force=config.force_device, test_driver=False) use(device=config.device, force=config.force_device, test_driver=False)
elif config.init_gpu_device.startswith('gpu'): elif config.init_gpu_device.startswith('gpu'):
assert config.device == "cpu", (
"We can use the Theano flag init_gpu_device"
" only when the Theano flag device=='cpu'")
_logger.warning(("GPU device %s will be initialized, and used if a GPU is " _logger.warning(("GPU device %s will be initialized, and used if a GPU is "
"needed. " "needed. "
"However, no computation, nor shared variables, will be implicitly " "However, no computation, nor shared variables, will be implicitly "
......
...@@ -232,7 +232,7 @@ class GpuConv(GpuKernelBase, gof.Op): ...@@ -232,7 +232,7 @@ class GpuConv(GpuKernelBase, gof.Op):
def c_code_cache_version(self): def c_code_cache_version(self):
# raise this whenever modifying any of the support_code_files # raise this whenever modifying any of the support_code_files
return (0, 21) return (0, 22)
def c_code(self, node, nodename, inp, out_, sub): def c_code(self, node, nodename, inp, out_, sub):
img, kern = inp img, kern = inp
......
...@@ -29,7 +29,6 @@ from .opt import gpu_seqopt, register_opt, conv_groupopt, op_lifter ...@@ -29,7 +29,6 @@ from .opt import gpu_seqopt, register_opt, conv_groupopt, op_lifter
from .opt_util import alpha_merge, output_merge, inplace_allocempty from .opt_util import alpha_merge, output_merge, inplace_allocempty
def dnn_available(): def dnn_available():
if dnn_available.avail is not None: if dnn_available.avail is not None:
return dnn_available.avail return dnn_available.avail
......
...@@ -437,7 +437,7 @@ class GpuElemwise(GpuKernelBase, HideC, Elemwise): ...@@ -437,7 +437,7 @@ class GpuElemwise(GpuKernelBase, HideC, Elemwise):
def c_code_cache_version(self): def c_code_cache_version(self):
ver = self.scalar_op.c_code_cache_version() ver = self.scalar_op.c_code_cache_version()
if ver: if ver:
return (3, ver) return (4, ver)
else: else:
return ver return ver
...@@ -542,7 +542,7 @@ class GpuDimShuffle(HideC, DimShuffle): ...@@ -542,7 +542,7 @@ class GpuDimShuffle(HideC, DimShuffle):
return process return process
def c_code_cache_version(self): def c_code_cache_version(self):
return (4,) return (5,)
class GpuCAReduceCuda(GpuKernelBase, HideC, CAReduceDtype): class GpuCAReduceCuda(GpuKernelBase, HideC, CAReduceDtype):
...@@ -791,7 +791,7 @@ class GpuCAReduceCuda(GpuKernelBase, HideC, CAReduceDtype): ...@@ -791,7 +791,7 @@ class GpuCAReduceCuda(GpuKernelBase, HideC, CAReduceDtype):
Py_XDECREF(%(z)s); Py_XDECREF(%(z)s);
%(z)s = pygpu_empty(%(nd_out)s, new_dims, %(z)s = pygpu_empty(%(nd_out)s, new_dims,
%(out_typecode)s, GA_C_ORDER, %(out_typecode)s, GA_C_ORDER,
%(ctx)s, Py_None); pygpu_default_context(), Py_None);
if (NULL == %(z)s) if (NULL == %(z)s)
{ {
PyErr_Format(PyExc_RuntimeError, "Failed to allocate output"); PyErr_Format(PyExc_RuntimeError, "Failed to allocate output");
...@@ -1911,7 +1911,7 @@ class GpuCAReduceCuda(GpuKernelBase, HideC, CAReduceDtype): ...@@ -1911,7 +1911,7 @@ class GpuCAReduceCuda(GpuKernelBase, HideC, CAReduceDtype):
""" % locals(), file=sio) """ % locals(), file=sio)
def c_code_cache_version_apply(self, node): def c_code_cache_version_apply(self, node):
version = [16] # the version corresponding to the c code in this Op version = [17] # the version corresponding to the c code in this Op
# now we insert versions for the ops on which we depend... # now we insert versions for the ops on which we depend...
version.extend(self.scalar_op.c_code_cache_version()) version.extend(self.scalar_op.c_code_cache_version())
...@@ -2884,7 +2884,7 @@ class GpuCAReduceCPY(GpuKernelBase, HideC, CAReduceDtype): ...@@ -2884,7 +2884,7 @@ class GpuCAReduceCPY(GpuKernelBase, HideC, CAReduceDtype):
return code return code
def c_code_cache_version(self): def c_code_cache_version(self):
return (1, self.GpuKernelBase_version) return (2, self.GpuKernelBase_version)
def generate_kernel(self, node, odtype, redux): def generate_kernel(self, node, odtype, redux):
if isinstance(self.scalar_op, scalar.basic.Add): if isinstance(self.scalar_op, scalar.basic.Add):
......
...@@ -40,7 +40,7 @@ class GpuImages2Neibs(GpuKernelBase, Images2Neibs, Op): ...@@ -40,7 +40,7 @@ class GpuImages2Neibs(GpuKernelBase, Images2Neibs, Op):
dtype=ten4.type.dtype)()]) dtype=ten4.type.dtype)()])
def c_code_cache_version(self): def c_code_cache_version(self):
return (10, 1) return (11,)
def c_headers(self): def c_headers(self):
return ['<numpy_compat.h>', '<gpuarray/types.h>'] return ['<numpy_compat.h>', '<gpuarray/types.h>']
......
...@@ -293,7 +293,7 @@ class GpuCrossentropySoftmaxArgmax1HotWithBias(GpuKernelBase, Op): ...@@ -293,7 +293,7 @@ class GpuCrossentropySoftmaxArgmax1HotWithBias(GpuKernelBase, Op):
return sio.getvalue() return sio.getvalue()
def c_code_cache_version(self): def c_code_cache_version(self):
return (7,) return (8,)
gpu_crossentropy_softmax_argmax_1hot_with_bias = GpuCrossentropySoftmaxArgmax1HotWithBias() gpu_crossentropy_softmax_argmax_1hot_with_bias = GpuCrossentropySoftmaxArgmax1HotWithBias()
...@@ -319,7 +319,7 @@ class GpuCrossentropySoftmax1HotWithBiasDx(GpuKernelBase, Op): ...@@ -319,7 +319,7 @@ class GpuCrossentropySoftmax1HotWithBiasDx(GpuKernelBase, Op):
return Apply(self, [dnll, sm, y_idx], [sm.type()]) return Apply(self, [dnll, sm, y_idx], [sm.type()])
def c_code_cache_version(self): def c_code_cache_version(self):
return (10,) return (11,)
def c_headers(self): def c_headers(self):
return ['<numpy_compat.h>', '<gpuarray/types.h>'] return ['<numpy_compat.h>', '<gpuarray/types.h>']
...@@ -524,7 +524,7 @@ class GpuSoftmax(GpuKernelBase, Op): ...@@ -524,7 +524,7 @@ class GpuSoftmax(GpuKernelBase, Op):
return shape return shape
def c_code_cache_version(self): def c_code_cache_version(self):
return (14,) + inline_softmax.code_version return (15,) + inline_softmax.code_version
def c_headers(self): def c_headers(self):
return ['<numpy_compat.h>', '<gpuarray/types.h>'] return ['<numpy_compat.h>', '<gpuarray/types.h>']
...@@ -718,7 +718,7 @@ class GpuSoftmaxWithBias (GpuKernelBase, Op): ...@@ -718,7 +718,7 @@ class GpuSoftmaxWithBias (GpuKernelBase, Op):
return [shape[0]] return [shape[0]]
def c_code_cache_version(self): def c_code_cache_version(self):
return (13,) + inline_softmax.code_version return (14,) + inline_softmax.code_version
def c_headers(self): def c_headers(self):
return ['<numpy_compat.h>', '<gpuarray/types.h>'] return ['<numpy_compat.h>', '<gpuarray/types.h>']
......
...@@ -394,7 +394,7 @@ class GpuIncSubtensor(GpuKernelBase, IncSubtensor): ...@@ -394,7 +394,7 @@ class GpuIncSubtensor(GpuKernelBase, IncSubtensor):
elemwise_version = self.iadd_node.c_code_cache_version() elemwise_version = self.iadd_node.c_code_cache_version()
if not parent_version or not elemwise_version: if not parent_version or not elemwise_version:
return return
return parent_version + elemwise_version + (2,) return parent_version + elemwise_version + (3,)
class GpuAdvancedSubtensor1(HideC, tensor.AdvancedSubtensor1): class GpuAdvancedSubtensor1(HideC, tensor.AdvancedSubtensor1):
......
...@@ -202,10 +202,10 @@ class GpuArrayType(Type): ...@@ -202,10 +202,10 @@ class GpuArrayType(Type):
def convert_variable(self, var): def convert_variable(self, var):
vt = var.type vt = var.type
if (type(self) == type(vt) and if (type(self) == type(vt) and
self.typecode == var.type.typecode and self.typecode == vt.typecode and
self.ndim == var.type.ndim and self.ndim == vt.ndim and
all(sb == ob or ob for sb, ob in zip(self.broadcastable, all(sb == ob or ob for sb, ob in zip(self.broadcastable,
var.type.broadcastable))): vt.broadcastable))):
return theano.tensor.patternbroadcast(var, self.broadcastable) return theano.tensor.patternbroadcast(var, self.broadcastable)
def __hash__(self): def __hash__(self):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论