提交 2a0cf5e1 authored 作者: abalkin's avatar abalkin

Fixed a crash when rank greater than numpy.MAXDIMS is requested in dimshuffle.

上级 89b18a8b
......@@ -340,6 +340,7 @@ class DimShuffle(Op):
#borrow only the writable flag from the base
# the NPY_OWNDATA flag will default to 0.
'(NPY_ARRAY_WRITEABLE*PyArray_ISWRITEABLE(%(basename)s)), NULL)'),
'if (%(res)s == NULL) %(fail)s;',
#recalculate flags: CONTIGUOUS, FORTRAN, ALIGNED
'PyArray_UpdateFlags(%(res)s, NPY_ARRAY_UPDATE_ALL)',
#we are making a view in both inplace and non-inplace cases
......
......@@ -95,6 +95,10 @@ class test_DimShuffle(unittest_tools.InferShapeTester):
[DimShuffle(ib, shuffle)(adtens)],
[adtens_val], DimShuffle)
def test_too_big_rank(self):
x = tensor.dscalar()
y = x.dimshuffle(('x',) * (numpy.MAXDIMS + 1))
self.assertRaises(ValueError, y.eval, {x: 0})
class test_Broadcast(unittest.TestCase):
def setUp(self):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论