-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PaddlePaddle Hackathon] add paddle.zeropad2d #36383
Conversation
Thanks for your contribution! |
|
||
def test_support_pad1(self): | ||
""" | ||
test the type of 'pad' is int. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int在上一个测例已经测过了,这里重复了吧
python/paddle/tensor/creation.py
Outdated
Args: | ||
x(Tensor): The input tensor with data type float32/float64/int32/int64. | ||
pad(Tensor | List[int] | Tuple[int]): The padding size with data type int. | ||
The input dimension should be 3 and pad has the form (pad_left, pad_right, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dimension should be 3 与 后面不一致
python/paddle/tensor/creation.py
Outdated
.. code-block:: text | ||
x = [[[[1., 2., 3.], | ||
[4., 5., 6.]]]] | ||
pad = [0, 0, 0, 0, 0, 0, 1, 1,] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里与上面参数描述不一致
|
||
x_dim = len(x.shape) | ||
|
||
assert x_dim == 4, "input tensor dimension should be 4, but got {}".format( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
输入Tensor一定要是4维吗
@@ -79,6 +79,7 @@ | |||
from .tensor.creation import ones_like # noqa: F401 | |||
from .tensor.creation import zeros # noqa: F401 | |||
from .tensor.creation import zeros_like # noqa: F401 | |||
from .tensor.creation import zeropad2d # noqa: F401 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
需要添加到all列表中,另外需要实现paddle.nn.ZeroPad2d
python/paddle/tensor/creation.py
Outdated
@@ -381,6 +381,75 @@ def zeros_like(x, dtype=None, name=None): | |||
return full_like(x=x, fill_value=0, dtype=dtype, name=name) | |||
|
|||
|
|||
def zeropad2d(x, pad, data_format="NCHW", name=None): | |||
""" | |||
Pad tensor with 0 according to 'pad'. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可以更详细一点,让别人看描述就知道用途甚至用法。
站在你自己看文档的角度,怎么描述可以让你更快速了解这个API是否是你需要的
Sorry to inform you that 1ba8ea6's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually. |
很多CI都挂了,需要解决一下哈 |
PR types
New features
PR changes
APIs
Describe
添加paddle.zeropad2d以及对应的测试案例