From 9f2d147d4f66d03f0bbd0dfb63d7499fbc08d768 Mon Sep 17 00:00:00 2001 From: littletomatodonkey Date: Thu, 23 Sep 2021 15:48:17 +0800 Subject: [PATCH 1/2] fix pad tuple --- python/paddle/nn/functional/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/paddle/nn/functional/common.py b/python/paddle/nn/functional/common.py index fcfbea438d7cc..6a703ac92581c 100644 --- a/python/paddle/nn/functional/common.py +++ b/python/paddle/nn/functional/common.py @@ -1274,7 +1274,7 @@ def pad(x, pad, mode='constant', value=0, data_format="NCHW", name=None): x_dim = len(x.shape) - if mode == "constant" and isinstance(pad, list) and len(pad) == x_dim * 2: + if mode == "constant" and isinstance(pad, (list, tuple)) and len(pad) == x_dim * 2: return layers.pad(x, pad, pad_value=value) assert x_dim in [ From 1855bfb4d532f241236db794e72993006d9a210e Mon Sep 17 00:00:00 2001 From: littletomatodonkey Date: Fri, 24 Sep 2021 09:37:28 +0800 Subject: [PATCH 2/2] fix format --- python/paddle/nn/functional/common.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/paddle/nn/functional/common.py b/python/paddle/nn/functional/common.py index 6a703ac92581c..fdd370d7f81e7 100644 --- a/python/paddle/nn/functional/common.py +++ b/python/paddle/nn/functional/common.py @@ -1274,7 +1274,8 @@ def pad(x, pad, mode='constant', value=0, data_format="NCHW", name=None): x_dim = len(x.shape) - if mode == "constant" and isinstance(pad, (list, tuple)) and len(pad) == x_dim * 2: + if mode == "constant" and isinstance(pad, ( + list, tuple)) and len(pad) == x_dim * 2: return layers.pad(x, pad, pad_value=value) assert x_dim in [