[Cpp API Compatibility] Add XPU device tests#78647
[Cpp API Compatibility] Add XPU device tests#78647youge325 wants to merge 3 commits intoPaddlePaddle:developfrom
Conversation
|
你的PR提交成功,感谢你对开源项目的贡献! |
There was a problem hiding this comment.
Pull request overview
This PR extends the C++ ATen/c10 compatibility test suite to cover XPU device behaviors, and updates the compat device→place mapping so “device without index” follows the current XPU device (mirroring existing CUDA behavior).
Changes:
- Add XPU-aware test branches for
c10::Device,at::Tensor::to(...),at::empty(...), andTensor::toBackend(...). - Change compat
c10::Device(DeviceType::XPU)(no index) to usepaddle::DefaultXPUPlace()instead of always using device 0. - Refactor compat
Tensor::to(...)device handling to usedev._PD_GetInner()for supported device types.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/cpp/compat/c10_Device_test.cc | Adds XPU current-device assertions for no-index c10::Device(c10::kXPU) when XPU is available. |
| test/cpp/compat/ATen_to_test.cc | Adds CPU→XPU and no-index-XPU-current-device to(...) tests; updates unsupported-device test. |
| test/cpp/compat/ATen_empty_test.cc | Adds XPU default-device (no index) coverage for at::empty(... device(at::kXPU)). |
| test/cpp/compat/ATen_basic_test.cc | Adds XPU current-device coverage for Tensor::toBackend(c10::Backend::XPU). |
| paddle/phi/api/include/compat/c10/core/Device.h | Changes XPU no-index device→place mapping to use DefaultXPUPlace() (current device). |
| paddle/phi/api/include/compat/ATen/ops/to.h | Uses Device::_PD_GetInner() for device transfer place resolution (covers XPU/IPU/CUSTOM). |
| paddle/phi/api/include/compat/ATen/core/TensorBody.h | Makes toBackend(XPU) use DefaultXPUPlace() (current device). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| case DeviceType::CUDA: | ||
| return has_index() ? phi::GPUPlace(index_) : paddle::DefaultGPUPlace(); | ||
| case DeviceType::XPU: | ||
| return phi::XPUPlace(has_index() ? index_ : 0); | ||
| return has_index() ? phi::XPUPlace(index_) : paddle::DefaultXPUPlace(); | ||
| case DeviceType::IPU: | ||
| return phi::IPUPlace(has_index() ? index_ : 0); | ||
| return has_index() ? phi::IPUPlace(index_) : phi::IPUPlace(); | ||
| case DeviceType::CUSTOM: |
There was a problem hiding this comment.
The PR description says it only adds XPU-related tests, but this change also modifies runtime behavior: XPU devices without an explicit index now resolve to paddle::DefaultXPUPlace() (current device) instead of always using device 0. Please update the PR description (or add release notes) to explicitly call out this semantics change, since it can affect existing users relying on the previous default-device behavior.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #78647 +/- ##
===========================================
Coverage ? 100.00%
===========================================
Files ? 3
Lines ? 17
Branches ? 0
===========================================
Hits ? 17
Misses ? 0
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
/re-run all-failed |
|
#78655 在修 fleet 流水线,需要等这个 PR 合入了 |
PR Category
Execute Infrastructure
PR Types
New features
Description
新增 XPU 相关测试,未显式指定 index 的 XPU device 现在会解析到当前 XPU device
是否引起精度变化
否