提交 a1bbaede authored 作者: Arnaud Bergeron's avatar Arnaud Bergeron

Update to the new signature for new_GpuArray().

上级 7459819e
......@@ -66,7 +66,7 @@ class HostFromGpu(Op):
} else {
%(name)s_ga = &%(inp)s->ga;
}
%(name)s_dtype = typecode_to_dtype(%(inp)s->ga.typecode);
%(name)s_dtype = typecode_to_dtype(%(name)s_ga->typecode);
Py_XDECREF(%(out)s);
// PyArray_Empty below steals a reference to the dtype we pass it
// so we need an extra one to spare.
......@@ -158,7 +158,7 @@ class GpuFromHost(Op):
%(fail)s
}
Py_XDECREF(%(out)s);
%(out)s = new_GpuArray((PyObject *)&GpuArrayType, GpuArray_default_context());
%(out)s = new_GpuArray((PyObject *)&GpuArrayType, GpuArray_default_context(), Py_None);
if (%(out)s == NULL) {
Py_DECREF(%(name)s_tmp);
// new_GpuArray calls __new__ which will set an error message
......@@ -191,7 +191,7 @@ class GpuFromHost(Op):
'out': outputs[0], 'fail': sub['fail']}
def c_code_cache_version(self):
return (1,)
return (2,)
gpu_from_host = GpuFromHost()
......@@ -298,7 +298,7 @@ class GpuFromCuda(Op):
}
Py_XDECREF(%(out)s);
%(out)s = new_GpuArray((PyObject *)&GpuArrayType, GpuArray_default_context());
%(out)s = new_GpuArray((PyObject *)&GpuArrayType, GpuArray_default_context(), Py_None);
if (%(out)s == NULL) {
free(%(name)sdims);
free(%(name)sstr);
......@@ -332,7 +332,7 @@ class GpuFromCuda(Op):
'fail': sub['fail']}
def c_code_cache_version(self):
return (1,)
return (2,)
gpu_from_cuda = GpuFromCuda()
......
......@@ -264,7 +264,7 @@ class GpuDimShuffle(DimShuffle):
}
Py_XDECREF(%(out)s);
%(out)s = new_GpuArray((PyObject *)&GpuArrayType, GpuArray_default_context());
%(out)s = new_GpuArray((PyObject *)&GpuArrayType, GpuArray_default_context(), Py_None);
if (%(out)s == NULL) {%(fail)s}
if (%(name)s_f(%(out)s, %(inp)s)) {
......@@ -289,4 +289,4 @@ class GpuDimShuffle(DimShuffle):
return process
def c_code_cache_version(self):
return (0,)
return (1,)
......@@ -77,7 +77,7 @@ class GpuSubtensor(Subtensor):
// Try to reuse the python object.
GpuArray_clear(&%(out)s->ga);
} else {
%(out)s = new_GpuArray((PyObject *)&GpuArrayType, GpuArray_default_context);
%(out)s = new_GpuArray((PyObject *)&GpuArrayType, GpuArray_default_context, Py_None);
}
if (!%(out)s) { %(fail)s }
int %(name)s_err;
......@@ -94,15 +94,4 @@ class GpuSubtensor(Subtensor):
return sio.getvalue()
def c_code_cache_version(self):
return (0,)
def grad(self, inputs, grads):
gz, = grads
x = inputs[0]
rest = inputs[1:]
output = self(*inputs)
if output.dtype.find('int') != -1:
first = x.zeros_like(theano.config.floatX)
else:
first = GpuIncSubtensor(self.idx_list)(x.zeros_like(), gz, *rest)
return ([first] + [DisconnectedType()()] * len(rest))
return (1,)
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论