提交 6290223c authored 作者: nouiz's avatar nouiz

Merge pull request #1087 from abalkin/dimshuffle-bug

Fixed a crash when rank greater than numpy.MAXDIMS is requested in dimshuffle.
......@@ -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,7 +95,11 @@ 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):
unittest_tools.seed_rng()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论