提交 567ef16c authored 作者: James Bergstra's avatar James Bergstra

added numpy source reference for dimshuffle

上级 44adeac0
......@@ -218,7 +218,8 @@ class DimShuffle(Op):
('strides['+str(i)+'] = 0')
for i, o in enumerate(self.new_order)]
#set the strides of the broadcasted dimensions
# set the strides of the broadcasted dimensions
# this algorithm is from numpy: PyArray_Newshape() in cvs/numpy/numpy/core/src/multiarraymodule.c
strides_statements.append('if (strides['+str(nd_out)+'-1] == 0) strides['+str(nd_out)+'-1] = %(basename)s->descr->elsize')
for i in xrange(nd_out-2,-1, -1):
strides_statements.append("if (strides[%(i)s] == 0) strides[%(i)s] = strides[%(i)s+1] * dimensions[%(i)s+1]"%dict(i=str(i)))
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论