[common] Add support for std::optional in error messages#78521
[common] Add support for std::optional in error messages#78521SigureMo merged 3 commits intoPaddlePaddle:developfrom
std::optional in error messages#78521Conversation
|
你的PR提交成功,感谢你对开源项目的贡献! |
There was a problem hiding this comment.
Pull request overview
This PR improves paddle/common/exception.h’s ErrorMessage builder (used by PD_CHECK / PD_THROW) to support formatting std::optional<T> values, so optional values can appear in error messages without compilation failures.
Changes:
- Add a
build_string(const std::optional<T>&)overload incommon::ErrorMessageto rendernulloptor the contained value. - Add C++ unit tests validating
ErrorMessageformatting forstd::optionaland thatPD_CHECKexceptions include optional content. - Register the new test in
test/cpp/utils/CMakeLists.txt.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
paddle/common/exception.h |
Adds std::optional formatting support inside ErrorMessage. |
test/cpp/utils/exception_test.cc |
New tests covering optional formatting + PD_CHECK throwing/message behavior. |
test/cpp/utils/CMakeLists.txt |
Adds exception_test target so the new tests run in CI. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@ShigureNyako 帮我看看 https://github.com/PaddlePaddle/Paddle/actions/runs/23706074064/job/69071406580?pr=78521 ,看起来 Linux-NPU 并没有使用 c++ 17 编译 |
…he conditional compilation macros
|
@ShigureNyako 排查一下 Coverage 为什么编译的那么慢 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #78521 +/- ##
===========================================
Coverage ? 100.00%
===========================================
Files ? 1
Lines ? 4
Branches ? 0
===========================================
Hits ? 4
Misses ? 0
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
std::optional in error messages
|
DCU 的 build 机器和其他的不一样,好像没有挂载跨机共享的 CFS,所以 cache 是每个机器独立的,这个 PR merge 后可能会有几个 PR 的 DCU build 会超时挂掉,待 cache 在每台机器上均匀分布之后才能恢复正常…… |
PR Category
Execute Infrastructure
PR Types
Devs
Description
在减少 paddlecodec diff 时发现,
PD_CHECK不支持std::optional相关输出相关链接
cc: @ShigureNyako
是否引起精度变化
否