| 34 | PD_REGISTER_API(from_blob) |
| 35 | |
| 36 | PADDLE_API phi::Place GetPlaceFromPtr(void* data) { |
| 37 | #if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) |
| 38 | #ifdef PADDLE_WITH_CUDA |
| 39 | cudaPointerAttributes attr = {}; |
| 40 | cudaError_t status = cudaPointerGetAttributes(&attr, data); |
| 41 | if (status == cudaSuccess && attr.type == cudaMemoryTypeDevice) { |
| 42 | return phi::GPUPlace(attr.device); |
| 43 | } |
| 44 | #else |
| 45 | hipPointerAttribute_t attr = {}; |
| 46 | hipError_t status = hipPointerGetAttributes(&attr, data); |
| 47 | if (status == hipSuccess && attr.memoryType == hipMemoryTypeDevice) { |
| 48 | return phi::GPUPlace(attr.device); |
| 49 | } |
| 50 | #endif |
| 51 | #endif |
| 52 | return phi::CPUPlace(); |
| 53 | } |
| 54 | |
| 55 | struct DeleterManager { |
| 56 | static DeleterManager* Instance() { |