提交 181939e0 authored 作者: Frederic Bastien's avatar Frederic Bastien

make the generated C code of DeepCopyOp work for CudaNdarray type.

上级 a1c1ca07
...@@ -189,7 +189,8 @@ class DeepCopyOp(theano.gof.Op): ...@@ -189,7 +189,8 @@ class DeepCopyOp(theano.gof.Op):
iname = inames[0] iname = inames[0]
oname = onames[0] oname = onames[0]
fail = sub['fail'] fail = sub['fail']
return """ if isinstance(node.inputs[0].type, theano.tensor.TensorType):
return """
Py_XDECREF(%(oname)s); Py_XDECREF(%(oname)s);
%(oname)s = (PyArrayObject*)PyArray_NewCopy(%(iname)s,NPY_ANYORDER); %(oname)s = (PyArrayObject*)PyArray_NewCopy(%(iname)s,NPY_ANYORDER);
...@@ -201,6 +202,19 @@ class DeepCopyOp(theano.gof.Op): ...@@ -201,6 +202,19 @@ class DeepCopyOp(theano.gof.Op):
} }
"""%locals() """%locals()
elif isinstance(node.inputs[0].type, theano.sandbox.cuda.CudaNdarrayType):
return """
Py_XDECREF(%(oname)s);
%(oname)s = (CudaNdarray*)CudaNdarray_Copy(%(iname)s);
if (!%(oname)s)
{
PyErr_SetString(PyExc_ValueError, "DeepCopyOp: the copy failed!");
%(fail)s;
}
"""%locals()
deep_copy_op = DeepCopyOp() deep_copy_op = DeepCopyOp()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论