| 89 | } |
| 90 | #elif defined(PADDLE_WITH_XPU) |
| 91 | PADDLE_API cudaStream_t GetCurrentCUDAStream(const phi::Place& place) { |
| 92 | PADDLE_ENFORCE_EQ(place.GetType(), |
| 93 | phi::AllocationType::XPU, |
| 94 | common::errors::InvalidArgument( |
| 95 | "GetCurrentCUDAStream only supports XPUPlace input. " |
| 96 | "However, your input is place=%s", |
| 97 | place)); |
| 98 | |
| 99 | auto& pool = paddle::experimental::DeviceContextPool::Instance(); |
| 100 | const phi::XPUContext* dev_ctx = |
| 101 | static_cast<const phi::XPUContext*>(pool.Get(place)); |
| 102 | return reinterpret_cast<cudaStream_t>(dev_ctx->stream()); |
| 103 | } |
| 104 | #endif |
| 105 | |
| 106 | } // namespace paddle |