Skip to content

Commit c88dbf2

Browse files
committed
add zeropad2d v0.3
1 parent af72a3b commit c88dbf2

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

python/paddle/fluid/tests/unittests/test_zeropad2d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def test_support_pad4(self):
104104
expect_res = np.pad(
105105
x, [[0, 0], [0, 0], [pad[2], pad[3]], [pad[0], pad[1]]])
106106

107-
x_tensor = to_tensor(x)
107+
x_tensor = to_tensor(x, dtype='int32')
108108
pad_tensor = to_tensor(pad)
109109
ret_res = zeropad2d(x_tensor, pad_tensor).numpy()
110110
self.assertTrue(np.allclose(expect_res, ret_res))

python/paddle/tensor/creation.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
from ..fluid.layers import utils
1919

2020
from ..fluid.layers import tensor
21-
from ..nn import functional as F
2221
from ..fluid.framework import Variable
2322
from ..fluid.framework import unique_name
2423
from ..fluid.framework import _current_expected_place, _get_paddle_place
@@ -805,12 +804,12 @@ def zeropad2d(x, pad, data_format="NCHW", name=None):
805804
# [0. 0. 0. 0. 0. 0.]]]]
806805
"""
807806

808-
return F.pad(x,
809-
pad=pad,
810-
mode='constant',
811-
value=0,
812-
data_format=data_format,
813-
name=name)
807+
return paddle.nn.functional.pad(x,
808+
pad=pad,
809+
mode='constant',
810+
value=0,
811+
data_format=data_format,
812+
name=name)
814813

815814

816815
def diagflat(x, offset=0, name=None):

0 commit comments

Comments
 (0)