提交 2b06f927 authored 作者: happygds's avatar happygds 提交者: GitHub

compatible when axis < 0 in tensor.roll()

上级 3c0be3d9
...@@ -4218,6 +4218,12 @@ def roll(x, shift, axis=None): ...@@ -4218,6 +4218,12 @@ def roll(x, shift, axis=None):
return roll(y, shift, axis=0).reshape(x.shape) return roll(y, shift, axis=0).reshape(x.shape)
else: else:
axis = 0 axis = 0
if axis < 0:
if x.ndim == 0:
axis = 0
else:
axis = axis % x.ndim + 1
# Shift may be larger than the size of the axis. If so, since the # Shift may be larger than the size of the axis. If so, since the
# roll operation is cyclic, we can take the shift modulo the size # roll operation is cyclic, we can take the shift modulo the size
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论