| 5 | namespace caffe { |
| 6 | |
| 7 | SyncedMemory::~SyncedMemory() { |
| 8 | if (cpu_ptr_ && own_cpu_data_) { |
| 9 | CaffeFreeHost(cpu_ptr_, cpu_malloc_use_cuda_); |
| 10 | } |
| 11 | |
| 12 | #ifndef CPU_ONLY |
| 13 | if (gpu_ptr_ && own_gpu_data_) { |
| 14 | int initial_device; |
| 15 | cudaGetDevice(&initial_device); |
| 16 | if (gpu_device_ != -1) { |
| 17 | CUDA_CHECK(cudaSetDevice(gpu_device_)); |
| 18 | } |
| 19 | CUDA_CHECK(cudaFree(gpu_ptr_)); |
| 20 | cudaSetDevice(initial_device); |
| 21 | } |
| 22 | #endif // CPU_ONLY |
| 23 | } |
| 24 | |
| 25 | inline void SyncedMemory::to_cpu() { |
| 26 | switch (head_) { |
nothing calls this directly
no test coverage detected