| 31 | |
| 32 | template <typename T> |
| 33 | void CopyToCPUHelper(std::vector<T> *cpu_, |
| 34 | Allocator::AllocationPtr *gpu_, |
| 35 | size_t *gpu_memory_size_) { |
| 36 | #if defined(PADDLE_WITH_CUSTOM_DEVICE) |
| 37 | // COPY Custom Device Data To CPU |
| 38 | auto *dev_ctx = static_cast<CustomContext *>( |
| 39 | DeviceContextPool::Instance().Get((*gpu_)->place())); |
| 40 | auto stream = dev_ctx->stream(); |
| 41 | void *src = (*gpu_)->ptr(); |
| 42 | void *dst = cpu_->data(); |
| 43 | memory_utils::Copy(CPUPlace(), |
| 44 | dst, |
| 45 | OptionalCustomPlace(*gpu_).get(), |
| 46 | src, |
| 47 | *gpu_memory_size_, |
| 48 | stream); |
| 49 | dev_ctx->Wait(); |
| 50 | #elif defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) |
| 51 | // COPY GPU Data To CPU |
| 52 | auto *dev_ctx = static_cast<GPUContext *>( |
| 53 | DeviceContextPool::Instance().Get((*gpu_)->place())); |
| 54 | auto stream = dev_ctx->stream(); |
| 55 | void *src = (*gpu_)->ptr(); |
| 56 | void *dst = cpu_->data(); |
| 57 | memory_utils::Copy(CPUPlace(), |
| 58 | dst, |
| 59 | OptionalCUDAPlace(*gpu_).get(), |
| 60 | src, |
| 61 | *gpu_memory_size_, |
| 62 | stream); |
| 63 | dev_ctx->Wait(); |
| 64 | #endif |
| 65 | } |
| 66 | |
| 67 | template <typename T> |
| 68 | void CopyCPUDataToCUDAHelper(std::vector<T> *cpu_, |
nothing calls this directly
no test coverage detected