提交 4e3c6ffa authored 作者: Frederic's avatar Frederic

Check the alignment after we check we got a return value!

上级 e0d4ff2a
...@@ -5973,7 +5973,7 @@ class Reshape(Op): ...@@ -5973,7 +5973,7 @@ class Reshape(Op):
return [tuple(oshape)] return [tuple(oshape)]
def c_code_cache_version(self): def c_code_cache_version(self):
return (3,) return (4,)
def c_code(self, node, name, inputs, outputs, sub): def c_code(self, node, name, inputs, outputs, sub):
if isinstance(node.inputs[0], TensorVariable): if isinstance(node.inputs[0], TensorVariable):
...@@ -6000,16 +6000,16 @@ class Reshape(Op): ...@@ -6000,16 +6000,16 @@ class Reshape(Op):
Py_XDECREF(%(z)s); Py_XDECREF(%(z)s);
%(z)s = (PyArrayObject *) PyArray_Newshape(%(x)s, &newshape, %(z)s = (PyArrayObject *) PyArray_Newshape(%(x)s, &newshape,
PyArray_CORDER); PyArray_CORDER);
if (!PyArray_ISALIGNED(%(z)s)) {
PyErr_Format(PyExc_RuntimeError, "PyArray_Newshape returned an object that isn't aligned!");
%(fail)s;
}
if (!%(z)s) if (!%(z)s)
{ {
PyErr_Format(PyExc_ValueError, PyErr_Format(PyExc_ValueError,
"Could not reshape array."); "Could not reshape array.");
%(fail)s; %(fail)s;
} }
if (!PyArray_ISALIGNED(%(z)s)) {
PyErr_Format(PyExc_RuntimeError, "PyArray_Newshape returned an object that isn't aligned!");
%(fail)s;
}
""" % locals() """ % locals()
else: else:
return Op.c_code(self, node, name, inputs, outputs, sub) return Op.c_code(self, node, name, inputs, outputs, sub)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论