diff --git a/python/paddle/fluid/layers/nn.py b/python/paddle/fluid/layers/nn.py index 59dfec005d852dc3da0f34b6b962002578afdb33..4216384b6f8b25b7ad7d09b6cca2cde504b6e1d8 100755 --- a/python/paddle/fluid/layers/nn.py +++ b/python/paddle/fluid/layers/nn.py @@ -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.") diff --git a/python/paddle/fluid/tests/unittests/test_slice_op.py b/python/paddle/fluid/tests/unittests/test_slice_op.py index f69993c52ae5d7bb9fc473536bd7c615c4841f62..a80dc87525ab803e56f02ad217d7431b1a18c7bc 100644 --- a/python/paddle/fluid/tests/unittests/test_slice_op.py +++ b/python/paddle/fluid/tests/unittests/test_slice_op.py @@ -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))