| 196 | |
| 197 | template <typename T> |
| 198 | void MultiTrainer::MergeToRootScope(phi::DenseTensor* root_tensor, |
| 199 | phi::DenseTensor* tensor) { |
| 200 | DenseTensor tmp_root; |
| 201 | TensorCopy(*root_tensor, CPUPlace(), &tmp_root); |
| 202 | T* tmp_root_data = tmp_root.data<T>(); |
| 203 | DenseTensor tmp_tensor; |
| 204 | TensorCopy(*tensor, CPUPlace(), &tmp_tensor); |
| 205 | T* data = tmp_tensor.data<T>(); |
| 206 | for (int i = 0; i < tmp_tensor.numel(); i++) { |
| 207 | tmp_root_data[i] += data[i]; |
| 208 | } |
| 209 | TensorCopy(tmp_root, CPUPlace(), root_tensor); |
| 210 | } |
| 211 | void MultiTrainer::MergeWorkerVars() { |
| 212 | for (size_t i = 0; i < need_merge_var_names_.size(); i++) { |
| 213 | Variable* root_var = root_scope_->FindVar(need_merge_var_names_[i]); |
nothing calls this directly
no test coverage detected