[Bug Fix] Support isfinite/isnan/isinf for float16/bfloat16 on CUDA/HIP#75933
Merged
luotao1 merged 4 commits intoPaddlePaddle:developfrom Oct 24, 2025
Merged
[Bug Fix] Support isfinite/isnan/isinf for float16/bfloat16 on CUDA/HIP#75933luotao1 merged 4 commits intoPaddlePaddle:developfrom
luotao1 merged 4 commits intoPaddlePaddle:developfrom
Conversation
- 在 isfinite_kernel_impl.h 的 GPU 侧 `Isfinite/Isnan/Isinf` 核函数里,把 “通用浮点” 模板拆成两支:一支只接受标准 `float/double`,另一支专门匹配 `phi::float16` 和 `phi::bfloat16`。这避免了 `std::is_floating_point` 对这两种自定义半精度类型返回 `false` 而导致完全没有匹配内核的情况,从而补齐了半精度在 CUDA/HIP 上的 `isfinite/isnan/isinf` 支持。 - 由于有了独立分支,调用的仍是对应的 `isfinite/isnan/isinf` 设备实现,逻辑保持一致,但现在 `float16/bfloat16` 会正确走到实际内核里,不再出现链接缺符号或运行时报 “未注册该数据类型” 的问题。 - 去掉三个模板 `IsfiniteKernel/IsinfKernel/IsnanKernel` 的 `PADDLE_API` 修饰,避免在头文件模板定义上做符号导出,引起重复导出或 Windows 下的装饰冲突。
|
你的PR提交成功,感谢你对开源项目的贡献! |
Contributor
Author
|
/re-run all-failed |
Contributor
Author
|
/re-run all-failed |
Contributor
Author
|
/re-run all-failed |
zhangbo9674
approved these changes
Oct 24, 2025
zyfncg
approved these changes
Oct 24, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Category
Environment Adaptation
PR Types
Bug fixes
Description
Isfinite/Isnan/Isinf核函数里,把 “通用浮点” 模板拆成两支:一支只接受标准float/double,另一支专门匹配phi::float16和phi::bfloat16。这避免了std::is_floating_point对这两种自定义半精度类型返回false而导致完全没有匹配内核的情况,从而补齐了半精度在 CUDA/HIP 上的isfinite/isnan/isinf支持。isfinite/isnan/isinf设备实现,逻辑保持一致,但现在float16/bfloat16会正确走到实际内核里,不再出现链接缺符号或运行时报 “未注册该数据类型” 的问题。IsfiniteKernel/IsinfKernel/IsnanKernel的PADDLE_API修饰,避免在头文件模板定义上做符号导出,引起重复导出或 Windows 下的装饰冲突。