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

Function CopyVar

test/cpp/imperative/test_gradient_accmulator.cc:260–277  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

258}
259
260static void CopyVar(const framework::Variable& var,
261 framework::Variable* dst_ptr) {
262 auto& dst = *dst_ptr;
263 dst.Clear();
264 if (var.IsType<phi::DenseTensor>()) {
265 const auto& src_tensor = var.Get<phi::DenseTensor>();
266 auto* dst_tensor = dst.GetMutable<phi::DenseTensor>();
267 framework::TensorCopySync(src_tensor, src_tensor.place(), dst_tensor);
268 } else {
269 const auto& src_selected_rows = var.Get<phi::SelectedRows>();
270 auto* dst_selected_rows = dst.GetMutable<phi::SelectedRows>();
271 dst_selected_rows->set_rows(src_selected_rows.rows());
272 dst_selected_rows->set_height(src_selected_rows.height());
273 framework::TensorCopySync(src_selected_rows.value(),
274 src_selected_rows.value().place(),
275 dst_selected_rows->mutable_value());
276 }
277}
278
279static bool IsEqualVar(const framework::Variable& var1,
280 const framework::Variable& var2) {

Calls 8

TensorCopySyncFunction · 0.50
ClearMethod · 0.45
placeMethod · 0.45
set_rowsMethod · 0.45
set_heightMethod · 0.45
heightMethod · 0.45
valueMethod · 0.45
mutable_valueMethod · 0.45

Tested by

no test coverage detected