-
Notifications
You must be signed in to change notification settings - Fork 5.9k
[Precision Depth Alignment] align paddle.nn.functional.interpolate forward #76246
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
Conversation
|
你的PR提交成功,感谢你对开源项目的贡献! |
d1823e5 to
6253096
Compare
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.
Pull Request Overview
This pull request aligns the precision and behavior of paddle.nn.functional.interpolate forward pass with reference implementations. The changes focus on improving numerical precision, adding anti-aliasing support for bilinear and bicubic interpolation modes, and refactoring the codebase for better maintainability.
Key Changes:
- Added anti-aliasing support for bilinear and bicubic interpolation modes with new
interp_antialiaskernel - Unified ratio computation logic using new
AreaPixelComputeScaleandAreaPixelComputeSourceIndexhelper functions - Changed ratio parameters from
floattodoublethroughout the codebase to improve precision - Renamed
get_cubic_upsample_coefficientstoGetCubicUpsampleCoefficientsfor naming consistency
Reviewed Changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| test/xpu/test_bilinear_interp_v2_op_xpu.py | Updated ratio computation logic to match new implementation |
| test/legacy_test/test_trilinear_interp_v2_op.py | Fixed compute_ratio function and corrected test parameters |
| test/legacy_test/test_nn_functional_interpolate.py | Removed anti-aliasing unsupported test (now supported) |
| test/legacy_test/test_bilinear_interp_v2_op.py | Added anti-aliasing tests and updated reference implementation |
| test/legacy_test/test_bicubic_interp_v2_op.py | Added anti-aliasing tests and updated reference implementation |
| python/paddle/nn/functional/common.py | Removed anti-aliasing restriction and added new operator integration |
| paddle/phi/ops/yaml/ops.yaml | Added interp_antialias operator definition |
| paddle/phi/ops/yaml/backward.yaml | Added interp_antialias_grad backward operator definition |
| paddle/phi/kernels/gpu/interpolate_kernel.cu | Implemented anti-aliasing kernels and improved precision with double |
| paddle/phi/kernels/gpu/interpolate_grad_kernel.cu | Updated gradient kernels to use double and fixed type casting |
| paddle/phi/kernels/funcs/interpolate_function.h | Added new helper functions and renamed existing functions |
| paddle/phi/kernels/cpu/interpolate_kernel.cc | Updated CPU kernels to use new helper functions |
| paddle/phi/kernels/cpu/interpolate_grad_kernel.cc | Updated CPU gradient kernels to use new helper functions |
| paddle/fluid/pir/dialect/operator/interface/infer_symbolic_shape/multiary_infer_sym.h | Added InterpAntialias symbolic shape inference declaration |
| paddle/fluid/pir/dialect/operator/interface/infer_symbolic_shape/multiary_infer_sym.cc | Added InterpAntialias symbolic shape inference implementation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #76246 +/- ##
==========================================
Coverage ? 38.29%
==========================================
Files ? 4
Lines ? 47
Branches ? 0
==========================================
Hits ? 18
Misses ? 29
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
dafe4e5 to
22eced9
Compare
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.
Copilot reviewed 15 out of 15 changed files in this pull request and generated 8 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
22eced9 to
96bdc86
Compare
96bdc86 to
0abe164
Compare
02ad71d to
87bdfd8
Compare
zhangting2020
left a comment
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 for [Distribute-stable-test / Test
wanghuancoder
left a comment
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
XiaoguangHu01
left a comment
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
…rward (PaddlePaddle#76246) * add antialias * fix acc * impl antialias * fix common * use new kernel * fix * fix * use AreaPixelComputeScale for cpu grad * fix large tensor issue * fix cov and test * fix AreaPixelComputeScale * unified PreCalculatorForLinearInterpInputIndex * fix test * disable test_weight_decay * fix
…75968) (#76588) * [Precision Depth Alignment] align paddle.lerp forward (#75968) * fix lerp forward * fix * fix decomp * fix comp * fix * fix lerp comp * fix comp * fix decomp * fix test * Modify the interpolate API and add 'antialias' argument (#76217) * [Precision Depth Alignment] align paddle.nn.functional.interpolate forward (#76246) * add antialias * fix acc * impl antialias * fix common * use new kernel * fix * fix * use AreaPixelComputeScale for cpu grad * fix large tensor issue * fix cov and test * fix AreaPixelComputeScale * unified PreCalculatorForLinearInterpInputIndex * fix test * disable test_weight_decay * fix * empty --------- Co-authored-by: Haze188 灏喆 <genghaozhe@baidu.com>
PR Category
Operator Mechanism
PR Types
Performance
Description
受影响的 API:
paddle.nn.functional.interpolate,新增对齐 case 3900/4769 个,现存精度问题case 620 个。修改内容
TODO
funcs::AreaPixelComputeScale 统一写成了funcs::AreaPixelComputeScale,后续需要修改成funcs::AreaPixelComputeScale
注意
torch 的 AreaPixelComputeScale 实现有一些问题,
上述 torch 等价实现中,当align_corners=False,scale=0, output_size=0 时,会出现x/0的情况,所以优化为下述实现(在合法情况下结果一致)。
Pcard-67164