| 74 | |
| 75 | template<typename Dtype> |
| 76 | GPUParams<Dtype>::GPUParams(shared_ptr<Solver<Dtype> > root_solver, int device) |
| 77 | : Params<Dtype>(root_solver) { |
| 78 | int initial_device; |
| 79 | CUDA_CHECK(cudaGetDevice(&initial_device)); |
| 80 | |
| 81 | // Allocate device buffers |
| 82 | CUDA_CHECK(cudaSetDevice(device)); |
| 83 | CUDA_CHECK(cudaMalloc(&data_, size_ * sizeof(Dtype))); |
| 84 | |
| 85 | // Copy blob values |
| 86 | const vector<Blob<Dtype>*>& net = |
| 87 | root_solver->net()->learnable_params(); |
| 88 | apply_buffers(net, data_, size_, copy); |
| 89 | |
| 90 | CUDA_CHECK(cudaMalloc(&diff_, size_ * sizeof(Dtype))); |
| 91 | caffe_gpu_set(size_, Dtype(0), diff_); |
| 92 | |
| 93 | CUDA_CHECK(cudaSetDevice(initial_device)); |
| 94 | } |
| 95 | |
| 96 | template<typename Dtype> |
| 97 | GPUParams<Dtype>::~GPUParams() { |
nothing calls this directly
no test coverage detected