Skip to content
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

[Werror] fix Werror-maybe-uninitialized in roi_align_grad_kernel #51633

Merged
merged 2 commits into from
Mar 20, 2023

Conversation

jinyouzhi
Copy link
Contributor

@jinyouzhi jinyouzhi commented Mar 14, 2023

PR types

Bug fixes

PR changes

Others

Describe

类似于 #51608 ,参考 #51605 #47143
修复 GCC 9.4.0 由于-Werror=maybe-uninitialized 引起的编译失败

/mnt/c/Users/jyz/Projects/pd/paddle/phi/kernels/cpu/roi_align_grad_kernel.cc: In function ‘void phi::RoiAlignGradKernel(const Context&, const phi::DenseTensor&, const phi::DenseTensor&, const paddle::optional<phi::DenseTensor>&, const phi::DenseTensor&, int, int, float, int, bool, phi::DenseTensor*) [with T = float; Context = phi::CPUContext]’:
/mnt/c/Users/jyz/Projects/pd/paddle/phi/kernels/cpu/roi_align_grad_kernel.cc:87:7: error: ‘*((void*)& in_dims +24)’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
   87 |   int width = in_dims[3];
      |       ^~~~~
/mnt/c/Users/jyz/Projects/pd/paddle/phi/kernels/cpu/roi_align_grad_kernel.cc:84:8: error:*((void*)& in_dims +16)’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
   84 |   auto in_dims = x.dims();
      |        ^~~~~~~
/mnt/c/Users/jyz/Projects/pd/paddle/phi/kernels/cpu/roi_align_grad_kernel.cc:85:7: error:*((void*)& in_dims +8)’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
   85 |   int channels = in_dims[1];
      |       ^~~~~~~~
/mnt/c/Users/jyz/Projects/pd/paddle/phi/kernels/cpu/roi_align_grad_kernel.cc: In function ‘void phi::RoiAlignGradKernel(const Context&, const phi::DenseTensor&, const phi::DenseTensor&, const paddle::optional<phi::DenseTensor>&, const phi::DenseTensor&, int, int, float, int, bool, phi::DenseTensor*) [with T = int; Context = phi::CPUContext]’:
/mnt/c/Users/jyz/Projects/pd/paddle/phi/kernels/cpu/roi_align_grad_kernel.cc:84:8: error:*((void*)& in_dims +24)’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
   84 |   auto in_dims = x.dims();
      |        ^~~~~~~
/mnt/c/Users/jyz/Projects/pd/paddle/phi/kernels/cpu/roi_align_grad_kernel.cc:84:8: error:*((void*)& in_dims +16)’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
/mnt/c/Users/jyz/Projects/pd/paddle/phi/kernels/cpu/roi_align_grad_kernel.cc:85:7: error:*((void*)& in_dims +8)’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
   85 |   int channels = in_dims[1];
      |       ^~~~~~~~
/mnt/c/Users/jyz/Projects/pd/paddle/phi/kernels/cpu/roi_align_grad_kernel.cc: In function ‘void phi::RoiAlignGradKernel(const Context&, const phi::DenseTensor&, const phi::DenseTensor&, const paddle::optional<phi::DenseTensor>&, const phi::DenseTensor&, int, int, float, int, bool, phi::DenseTensor*) [with T = double; Context = phi::CPUContext]’:
/mnt/c/Users/jyz/Projects/pd/paddle/phi/kernels/cpu/roi_align_grad_kernel.cc:87:7: error:*((void*)& in_dims +24)’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
   87 |   int width = in_dims[3];
      |       ^~~~~
/mnt/c/Users/jyz/Projects/pd/paddle/phi/kernels/cpu/roi_align_grad_kernel.cc:84:8: error:*((void*)& in_dims +16)’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
   84 |   auto in_dims = x.dims();
      |        ^~~~~~~
/mnt/c/Users/jyz/Projects/pd/paddle/phi/kernels/cpu/roi_align_grad_kernel.cc:85:7: error:*((void*)& in_dims +8)’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
   85 |   int channels = in_dims[1];
      |       ^~~~~~~~
cc1plus: all warnings being treated as errors
make[2]: *** [paddle/phi/kernels/CMakeFiles/phi_cpu.dir/build.make:4346: paddle/phi/kernels/CMakeFiles/phi_cpu.dir/cpu/roi_align_grad_kernel.cc.o] Error 1

@paddle-bot
Copy link

paddle-bot bot commented Mar 14, 2023

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@paddle-bot paddle-bot bot added contributor External developers status: proposed labels Mar 14, 2023
@paddle-bot
Copy link

paddle-bot bot commented Mar 14, 2023

❌ The PR is not created using PR's template. You can refer to this Demo.
Please use PR's template, it helps save our maintainers' time so that more developers get helped.

@jinyouzhi jinyouzhi marked this pull request as ready for review March 14, 2023 11:16
@jinyouzhi
Copy link
Contributor Author

@zhiqiu CI都过了

@@ -81,7 +81,7 @@ void RoiAlignGradKernel(const Context& dev_ctx,
int sampling_ratio,
bool aligned,
DenseTensor* dx) {
auto in_dims = x.dims();
auto in_dims = phi::vectorize<int>(x.dims());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是不是改成const auto&也可以?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好的,我本地试一下

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zhiqiu 确实可以!

@jinyouzhi jinyouzhi requested a review from zhiqiu March 17, 2023 10:11
Copy link
Contributor

@zhiqiu zhiqiu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zhiqiu zhiqiu merged commit 5786f3e into PaddlePaddle:develop Mar 20, 2023
@jinyouzhi jinyouzhi deleted the werror/uninit branch August 29, 2023 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants