提交 960ccba1 authored 作者: Hengjean's avatar Hengjean

Added sanity check to shape_i

上级 b0d922e9
......@@ -372,8 +372,14 @@ class Shape_i(gof.Op):
itype = node.inputs[0].type.__class__
if itype in self.c_code_and_version:
sc = """
if (%(i)s>PyArray_NDIM(%(iname)s){
PyErr_SetString(PyExc_TypeError, "Number of dimensions lower than expected");
%(fail)s
}
""" % locals()
code, version = self.c_code_and_version[itype]
return code % locals()
return sc + code % locals()
# Else, no C code
return super(Shape_i, self).c_code(node, name, inames, onames, sub)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论