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

[Fix] fix phi extension header error when compiling custom device #60842

Merged
merged 7 commits into from
Jan 17, 2024

Conversation

qili93
Copy link
Contributor

@qili93 qili93 commented Jan 16, 2024

PR types

Bug fixes

PR changes

Others

Description

修复 #57785 引入的 extension.h 的头文件问题

文件栈如下,kernels.h 是由Paddle自动生成,会自动引入所有 paddle/phi/include/ 目录下的kernel头文件

copysign_kernel.h 中引入了 elementwise_base.h,这里代码有对 set_lod 这样定义在 dense_tensor_impl.inl 中而不是 dense_tensor.h 中的定义进行引用,外部调用 extension.h 头文件就会引发找不到 set_lod 定义的错误,因此 elementwise_base.h 这样头文件的引入需要放在kernel.cc/kernel.cu文件中,不可以放到 kernel.h的头文件中。

2024-01-15 16:46:16 In file included from /opt/py39/lib/python3.9/site-packages/paddle/include/paddle/phi/kernels/funcs/eigen/common.h:20,
2024-01-15 16:46:16                  from /opt/py39/lib/python3.9/site-packages/paddle/include/paddle/phi/kernels/funcs/common_shape.h:18,
2024-01-15 16:46:16                  from /opt/py39/lib/python3.9/site-packages/paddle/include/paddle/phi/kernels/funcs/elementwise_base.h:21,
2024-01-15 16:46:16                  from /opt/py39/lib/python3.9/site-packages/paddle/include/paddle/phi/kernels/funcs/broadcast_function.h:18,
2024-01-15 16:46:16                  from /opt/py39/lib/python3.9/site-packages/paddle/include/paddle/phi/kernels/copysign_kernel.h:18,
2024-01-15 16:46:16                  from /opt/py39/lib/python3.9/site-packages/paddle/include/paddle/phi/include/kernels.h:65,
2024-01-15 16:46:16                  from /opt/py39/lib/python3.9/site-packages/paddle/include/paddle/phi/extension.h:11,

后续为了避免此类情况,增加一个 header_test 的测试

  1. 在develop分支,没有修复copysign_kernel代码的情况下会报编译错误如下

d8c55f4315ad73e1f06ebdc42575069e

  1. 在修复了 copysign_kernel 代码之后可以正常编译和执行单测如下

image

Pcard-77889

Copy link

paddle-bot bot commented Jan 16, 2024

你的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.

Copy link
Contributor

@ronny1996 ronny1996 left a comment

Choose a reason for hiding this comment

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

LGTM

@qili93 qili93 merged commit 80f0bb7 into PaddlePaddle:develop Jan 17, 2024
29 checks passed
@qili93 qili93 deleted the fix_extention_header branch January 17, 2024 05:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants