提交 54bfc88a authored 作者: Arnaud Bergeron's avatar Arnaud Bergeron

Adapt to the new api for GpuElemwise.

上级 3fbcbf65
......@@ -179,10 +179,9 @@ class GpuElemwise(HideC, Elemwise):
for n, (i, name) in enumerate(zip(node.inputs, inps)):
res += """
args[%(n)s].name = %(name)s;
args[%(n)s].nd = %(nd)s;
args[%(n)s].typecode = %(typecode)s;
args[%(n)s].flags = GE_READ;
""" % dict(n=n, name='"%s"' % (name,), nd=i.ndim,
""" % dict(n=n, name='"%s"' % (name,),
typecode=i.type.typecode)
p = 0
......@@ -195,21 +194,20 @@ class GpuElemwise(HideC, Elemwise):
p += 1
res += """
args[%(n)s].name = %(name)s;
args[%(n)s].nd = %(nd)s;
args[%(n)s].typecode = %(typecode)s;
args[%(n)s].flags = GE_WRITE;
""" % dict(n=nn, name='"%s"' % (name,), nd=o.ndim,
""" % dict(n=nn, name='"%s"' % (name,),
typecode=o.type.typecode)
res += """
ge = GpuElemwise_new(%(ctx)s->ops, %(ctx)s->ctx, %(support)s, %(kop)s, %(nargs)s, args, 0);
ge = GpuElemwise_new(%(ctx)s->ops, %(ctx)s->ctx, %(support)s, %(kop)s, %(nargs)s, args, %(nd)s, 0);
if (ge == NULL) {
PyErr_SetString(PyExc_RuntimeError, "Could not initialize elemwise support");
%(fail)s
}
""" % dict(nargs=nargs, ctx=sub['params'], fail=sub['fail'],
support=as_C_string_const(support_code),
kop=as_C_string_const(kop))
kop=as_C_string_const(kop), nd=node.inputs[0].ndim)
return res
......@@ -357,7 +355,7 @@ class GpuElemwise(HideC, Elemwise):
def c_code_cache_version(self):
ver = self.scalar_op.c_code_cache_version()
if ver:
return (5, ver)
return (6, ver)
else:
return ver
......
......@@ -340,13 +340,11 @@ class GpuIncSubtensor(IncSubtensor):
args[0].name = "a";
args[0].typecode = %(type1)s;
args[0].flags = GE_READ|GE_WRITE;
args[0].nd = %(nd)s;
args[1].name = "b";
args[1].typecode = %(type2)s;
args[1].flags = GE_READ;
args[1].nd = %(nd)s;
iadd = GpuElemwise_new(%(ctx)s->ops, %(ctx)s->ctx, "", "a += b",
2, args, 0);
2, args, %(nd)s, 0);
if (iadd == NULL) {
PyErr_SetString(PyExc_RuntimeError, "Could not intialize inplace add support");
%(fail)s
......@@ -374,7 +372,7 @@ class GpuIncSubtensor(IncSubtensor):
parent_version = super(GpuIncSubtensor, self).c_code_cache_version()
if not parent_version:
return
return parent_version + (4,)
return parent_version + (5,)
class GpuAdvancedSubtensor1(HideC, tensor.AdvancedSubtensor1):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论