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

Changes following review.

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