未验证 提交 b53887fd 编写于 作者: W WeiXin 提交者: GitHub

fix bug:When axes in paddle.slice is a tuple, an error occurs. (#35267)

* fix bug:When axes in paddle.sile is a tuple, an error occurs.

* polish code.
上级 3c21f26b
......@@ -10977,6 +10977,7 @@ def slice(input, axes, starts, ends):
ends_tensor = None
if isinstance(axes, (list, tuple)):
axes = list(axes)
if len(axes) == 0:
raise ValueError(
"Input axes should not be an empty list/tuple.")
......
......@@ -705,7 +705,7 @@ class TestInferShape(unittest.TestCase):
np_slice = x_arr[:, :, 0:1]
self.assertTrue(np.array_equal(pp_slice, np_slice))
pp_slice = paddle.slice(x, [-100, ], [0], [1])
pp_slice = paddle.slice(x, (-100, ), [0], [1])
np_slice = x_arr[0:1]
self.assertTrue(np.array_equal(pp_slice, np_slice))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册