MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / MergeToRootScope

Method MergeToRootScope

paddle/fluid/framework/multi_trainer.cc:198–210  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

196
197template <typename T>
198void 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}
211void 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]);

Callers

nothing calls this directly

Calls 3

TensorCopyFunction · 0.85
CPUPlaceClass · 0.50
numelMethod · 0.45

Tested by

no test coverage detected