| 57 | // Buffer size necessary to store given blobs |
| 58 | template<typename Dtype> |
| 59 | static size_t total_size(const vector<Blob<Dtype>*>& params) { |
| 60 | size_t size = 0; |
| 61 | for (int i = 0; i < params.size(); ++i) |
| 62 | size += params[i]->count(); |
| 63 | // Size have at least one byte, otherwise cudaMalloc fails if net has no |
| 64 | // learnable parameters. |
| 65 | return (size > 0) ? size : 1; |
| 66 | } |
| 67 | |
| 68 | template<typename Dtype> |
| 69 | Params<Dtype>::Params(shared_ptr<Solver<Dtype> > root_solver) |