提交 69e00eb1 authored 作者: Reyhane Askari's avatar Reyhane Askari

minor changes in GpuJoin C code and test_GpuJoin

上级 2c57648f
......@@ -1349,15 +1349,16 @@ class GpuJoin(HideC, Join):
%(fail)s
}
}
int tensors_lens_sum = 0""" % locals()
int tensors_lens_sum;
if(%(view)s != -1){
tensors_lens_sum = 0""" % locals()
for inp in tensors:
code += """ + PyGpuArray_DIM(%(inp)s, axis)""" % locals()
code += """;\n
tensors_lens_sum -= PyGpuArray_DIM(%(non_empty_tensor)s, axis);
}
if(%(view)s != -1 && tensors_lens_sum == 0){
Py_XDECREF(%(out)s);
Py_INCREF(%(non_empty_tensor)s);
%(out)s = %(non_empty_tensor)s;
}
......@@ -1366,8 +1367,8 @@ class GpuJoin(HideC, Join):
%(restype)s, (PyObject *)&PyGpuArrayType,
%(ctx)s);
}
PyMem_Free(als);
}
PyMem_Free(als);
if (%(out)s == NULL)
%(fail)s
......
......@@ -465,13 +465,12 @@ def test_Gpujoin_inplace():
"""
s = T.lscalar()
data = numpy.array([3, 4, 5], dtype=theano.config.floatX)
x = theano.shared(data, borrow=True)
x = gpuarray_shared_constructor(data, borrow=True)
z = T.zeros((s,))
join = GpuJoin(view=0)
c = join(0, x, z)
f = theano.function([s], theano.Out(c, borrow=True))
assert x.get_value(borrow=True, return_internal_type=True) is f(0)
assert numpy.allclose(f(0), [3, 4, 5])
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论