-
Notifications
You must be signed in to change notification settings - Fork 825
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
Fix upsample bilinear bug #5366
Conversation
Co-authored-by: oneflow-ci-bot <69100618+oneflow-ci-bot@users.noreply.github.com>
…w-Inc/oneflow into fix_upsample_bilinear_bug
return align_corners ? static_cast<T>(input_size - 1) / (output_size - 1) | ||
: (scale > 0. ? 1.0 / scale : static_cast<T>(input_size) / output_size); | ||
} else { | ||
return 0; |
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.
我总感觉 pytorch output_size == 1 的时候 scale 直接 return 0 是个 bug,没有找到它为什么这么写的原理
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.
opencv是没有这个判断的,我也同意这个地方有问题,那这里还要不要特判。。
@@ -98,14 +87,32 @@ template<typename T> | |||
__device__ void GetBilinearParam(const bool align_corners, const int64_t h, const int64_t w, |
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.
.cu 和 .cpp 的 GetAreaPixelScale 和 GetBilinearParam 函数的实现是不是可以复用
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.
好的
const int64_t in_h = GetNearestInputIndex(h, scale_h, in_height); | ||
const int64_t in_w = GetNearestInputIndex(w, scale_w, in_width); | ||
const int64_t in_h = GetNearestInputIndexFunc(h, scale_h, in_height); | ||
const int64_t in_w = GetNearestInputIndexFunc(w, scale_w, in_width); |
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.
命名里的 Func 是不是可以去掉
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.
好的
重构代码,和Pytorch完全对齐。
https://github.com/Quansight/pytorch/blob/74519b2a89039c5c77dfdfdd01d6fc23ca6d0367/aten/src/ATen/native/UpSampleBilinear2d.cpp#L60