Add unpool2d op & Expose max_unpool2d API#35056
Merged
ceci3 merged 11 commits intoPaddlePaddle:developfrom Aug 27, 2021
Merged
Conversation
|
Thanks for your contribution! |
| int cidx = boffset / in_c_stride; | ||
| int out_offset = bidx * out_n_stride + cidx * out_c_stride; | ||
| int out_index = indices_data[i]; | ||
| PADDLE_ENFORCE(out_index < out_c_stride, |
Contributor
There was a problem hiding this comment.
为啥去掉这块的enforce呢?建议再check下数据数据检查
| out_index, out_c_stride, out_index, out_c_stride); | ||
| output_data[out_offset + out_index] = input_data[i]; | ||
| CUDA_KERNEL_LOOP(linearIndex, nthreads) { | ||
| int c = (linearIndex / input_width / input_height) % channels; |
Contributor
There was a problem hiding this comment.
异常数据注意enforce,否则安全扫描可能有问题
Contributor
Author
There was a problem hiding this comment.
thx,下一个PR中添加异常数据检查
jeff41404
reviewed
Aug 25, 2021
python/paddle/nn/layer/__init__.py
Outdated
| from .pooling import AdaptiveMaxPool1D # noqa: F401 | ||
| from .pooling import AdaptiveMaxPool2D # noqa: F401 | ||
| from .pooling import AdaptiveMaxPool3D # noqa: F401 | ||
| from .pooling import MaxUnPool2D |
jeff41404
reviewed
Aug 25, 2021
| namespace ops = paddle::operators; | ||
| REGISTER_OP_CUDA_KERNEL( | ||
| unpool, ops::UnpoolKernel<paddle::platform::CUDADeviceContext, float>, | ||
| unpool2d, ops::UnpoolKernel<paddle::platform::CUDADeviceContext, float>, |
Contributor
There was a problem hiding this comment.
因为改名,需要确认下是否之前有API使用了unpool
Contributor
Author
There was a problem hiding this comment.
在全景图里做了搜索,确认没有api使用过unpool
jzhang533
approved these changes
Aug 27, 2021
Contributor
jzhang533
left a comment
There was a problem hiding this comment.
still need to improve docstring.
| import numpy as np | ||
|
|
||
| data = paddle.to_tensor(np.random.uniform(-1, 1, [1, 1, 7, 7]).astype(np.float32)) | ||
| pool_out, indices = F.max_pool2d(data, kernel_size=2, stride=2, padding=0, return_mask=True) |
Contributor
There was a problem hiding this comment.
构造数据可以直接用paddle.randn吧,这样可以不依赖numpy。
Contributor
Author
There was a problem hiding this comment.
好的~ 会在文档修复PR中更新example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR types
New features
PR changes
Ops
Describe
Add max_unpool2d operation