-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Add unpool2d op & Expose max_unpool2d API #35056
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, |
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.
为啥去掉这块的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; |
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.
异常数据注意enforce,否则安全扫描可能有问题
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.
thx,下一个PR中添加异常数据检查
python/paddle/nn/layer/__init__.py
Outdated
@@ -54,6 +54,7 @@ | |||
from .pooling import AdaptiveMaxPool1D # noqa: F401 | |||
from .pooling import AdaptiveMaxPool2D # noqa: F401 | |||
from .pooling import AdaptiveMaxPool3D # noqa: F401 | |||
from .pooling import MaxUnPool2D |
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.
加上 # 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.
done, thx
@@ -16,9 +16,9 @@ limitations under the License. */ | |||
|
|||
namespace ops = paddle::operators; | |||
REGISTER_OP_CUDA_KERNEL( | |||
unpool, ops::UnpoolKernel<paddle::platform::CUDADeviceContext, float>, | |||
unpool2d, ops::UnpoolKernel<paddle::platform::CUDADeviceContext, float>, |
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使用了unpool
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使用过unpool
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.
lgtm
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.
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) |
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.
构造数据可以直接用paddle.randn
吧,这样可以不依赖numpy。
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.
好的~ 会在文档修复PR中更新example
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.
LG API
PR types
New features
PR changes
Ops
Describe
Add max_unpool2d operation