提交 87cd5536 authored 作者: Arnaud Bergeron's avatar Arnaud Bergeron

Add second batch of changes and bump the cache versions.

上级 e2fb6451
...@@ -42,7 +42,7 @@ register_transfer(transfer) ...@@ -42,7 +42,7 @@ register_transfer(transfer)
def init_dev(dev, name=None): def init_dev(dev, name=None):
v = pygpu.gpuarray.api_version() v = pygpu.gpuarray.api_version()
expected = -9998 expected = -9997
if v[0] != expected: if v[0] != expected:
raise RuntimeError("Wrong major API version for gpuarray:", v[0], raise RuntimeError("Wrong major API version for gpuarray:", v[0],
"Make sure Theano and libgpuarray/pygpu " "Make sure Theano and libgpuarray/pygpu "
......
...@@ -259,14 +259,14 @@ class GpuKernelBase(object): ...@@ -259,14 +259,14 @@ class GpuKernelBase(object):
int types[%(numargs)u] = {%(types)s}; int types[%(numargs)u] = {%(types)s};
const char *bcode = %(bvar)s; const char *bcode = %(bvar)s;
size_t sz = sizeof(%(bvar)s); size_t sz = sizeof(%(bvar)s);
if (GpuKernel_init(&%(ovar)s, %(ctx)s->ops, %(ctx)s->ctx, 1, &bcode, &sz, if (GpuKernel_init(&%(ovar)s, %(ctx)s->ctx, 1, &bcode, &sz,
"%(kname)s", %(numargs)u, types, GA_USE_BINARY, NULL) "%(kname)s", %(numargs)u, types, GA_USE_BINARY, NULL)
!= GA_NO_ERROR) { != GA_NO_ERROR) {
if ((err = GpuKernel_init(&%(ovar)s, %(ctx)s->ops, %(ctx)s->ctx, 1, if ((err = GpuKernel_init(&%(ovar)s, %(ctx)s->ctx, 1,
&%(cname)s, NULL, "%(kname)s", %(numargs)u, &%(cname)s, NULL, "%(kname)s", %(numargs)u,
types, %(flags)s, NULL)) != GA_NO_ERROR) { types, %(flags)s, NULL)) != GA_NO_ERROR) {
PyErr_Format(PyExc_RuntimeError, "GpuKernel_init error %%d: %%s", PyErr_Format(PyExc_RuntimeError, "GpuKernel_init error %%d: %%s",
err, Gpu_error(%(ctx)s->ops, %(ctx)s->ctx, err)); err, gpucontext_error(%(ctx)s->ctx, err));
%(fail)s %(fail)s
} }
} }
...@@ -310,7 +310,7 @@ class GpuKernelBase(object): ...@@ -310,7 +310,7 @@ class GpuKernelBase(object):
The node that we need the cache version for. The node that we need the cache version for.
""" """
return (3, self.get_params(node).bin_id) return (4, self.get_params(node).bin_id)
class HostFromGpu(Op): class HostFromGpu(Op):
......
...@@ -199,7 +199,7 @@ class GpuElemwise(HideC, Elemwise): ...@@ -199,7 +199,7 @@ class GpuElemwise(HideC, Elemwise):
typecode=o.type.typecode) typecode=o.type.typecode)
res += """ res += """
ge = GpuElemwise_new(%(ctx)s->ops, %(ctx)s->ctx, %(support)s, %(kop)s, %(nargs)s, args, %(nd)s, 0); ge = GpuElemwise_new(%(ctx)s->ctx, %(support)s, %(kop)s, %(nargs)s, args, %(nd)s, 0);
if (ge == NULL) { if (ge == NULL) {
PyErr_SetString(PyExc_RuntimeError, "Could not initialize elemwise support"); PyErr_SetString(PyExc_RuntimeError, "Could not initialize elemwise support");
%(fail)s %(fail)s
...@@ -360,7 +360,7 @@ class GpuElemwise(HideC, Elemwise): ...@@ -360,7 +360,7 @@ class GpuElemwise(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 (6, ver) return (7, ver)
else: else:
return ver return ver
......
...@@ -26,11 +26,8 @@ class GpuCumsum(GpuKernelBase, Op): ...@@ -26,11 +26,8 @@ class GpuCumsum(GpuKernelBase, Op):
def __init__(self, axis): def __init__(self, axis):
self.axis = axis self.axis = axis
def __str__(self): def c_code_cache_version(self):
return "%s{%s}" % (self.__class__.__name__, self.axis) return (2,)
def c_code_cache_version_apply(self, node):
return (1,)
def c_headers(self): def c_headers(self):
return ['<numpy_compat.h>', '<gpuarray/types.h>', '<gpuarray_helper.h>'] return ['<numpy_compat.h>', '<gpuarray/types.h>', '<gpuarray_helper.h>']
......
...@@ -105,7 +105,7 @@ class Gemm16(COp): ...@@ -105,7 +105,7 @@ class Gemm16(COp):
return """ return """
bcode = bin_%(name)s; bcode = bin_%(name)s;
sz = sizeof(bin_%(name)s); sz = sizeof(bin_%(name)s);
if (GpuKernel_init(&k_%(name)s, c->ops, c->ctx, 1, &bcode, &sz, if (GpuKernel_init(&k_%(name)s, c->ctx, 1, &bcode, &sz,
"hgemm_%(name)s", 13, types, GA_USE_BINARY, NULL) "hgemm_%(name)s", 13, types, GA_USE_BINARY, NULL)
!= GA_NO_ERROR) { != GA_NO_ERROR) {
PyErr_SetString(PyExc_RuntimeError, "Could not initialize kernel %(name)s"); PyErr_SetString(PyExc_RuntimeError, "Could not initialize kernel %(name)s");
......
...@@ -340,7 +340,7 @@ class GpuIncSubtensor(IncSubtensor): ...@@ -340,7 +340,7 @@ class GpuIncSubtensor(IncSubtensor):
args[1].name = "b"; args[1].name = "b";
args[1].typecode = %(type2)s; args[1].typecode = %(type2)s;
args[1].flags = GE_READ; args[1].flags = GE_READ;
iadd = GpuElemwise_new(%(ctx)s->ops, %(ctx)s->ctx, "", "a += b", iadd = GpuElemwise_new(%(ctx)s->ctx, "", "a += b",
2, args, %(nd)s, 0); 2, args, %(nd)s, 0);
if (iadd == NULL) { if (iadd == NULL) {
PyErr_SetString(PyExc_RuntimeError, "Could not intialize inplace add support"); PyErr_SetString(PyExc_RuntimeError, "Could not intialize inplace add support");
...@@ -369,7 +369,7 @@ class GpuIncSubtensor(IncSubtensor): ...@@ -369,7 +369,7 @@ class GpuIncSubtensor(IncSubtensor):
parent_version = super(GpuIncSubtensor, self).c_code_cache_version() parent_version = super(GpuIncSubtensor, self).c_code_cache_version()
if not parent_version: if not parent_version:
return return
return parent_version + (5,) return parent_version + (6,)
class GpuAdvancedSubtensor1(HideC, tensor.AdvancedSubtensor1): class GpuAdvancedSubtensor1(HideC, tensor.AdvancedSubtensor1):
...@@ -437,8 +437,7 @@ if (err != GA_NO_ERROR) { ...@@ -437,8 +437,7 @@ if (err != GA_NO_ERROR) {
if (err == GA_VALUE_ERROR) { if (err == GA_VALUE_ERROR) {
PyErr_SetString(PyExc_IndexError, "Index out of bounds."); PyErr_SetString(PyExc_IndexError, "Index out of bounds.");
} else { } else {
PyErr_SetString(PyExc_RuntimeError, Gpu_error(%(v)s->context->ops, PyErr_SetString(PyExc_RuntimeError, GpuArray_error(&%(v)s->ga, err));
%(v)s->context->ctx, err));
} }
%(fail)s %(fail)s
} }
...@@ -589,7 +588,7 @@ class GpuAdvancedIncSubtensor1_dev20(GpuKernelBase, GpuAdvancedIncSubtensor1): ...@@ -589,7 +588,7 @@ class GpuAdvancedIncSubtensor1_dev20(GpuKernelBase, GpuAdvancedIncSubtensor1):
return super(GpuAdvancedIncSubtensor1_dev20, self).perform(node, inp, out) return super(GpuAdvancedIncSubtensor1_dev20, self).perform(node, inp, out)
def c_code_cache_version(self): def c_code_cache_version(self):
return (6,) return (7,)
def c_headers(self): def c_headers(self):
return ['<numpy_compat.h>', '<gpuarray_helper.h>', return ['<numpy_compat.h>', '<gpuarray_helper.h>',
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论