From 24e24987f0366618cc29e381e26ef4767525455b Mon Sep 17 00:00:00 2001 From: mapingshuo Date: Mon, 8 Jun 2020 14:29:54 +0800 Subject: [PATCH] fixes the place info in the Print op (#24934) fixes the CUDAPlace info in the Print op --- paddle/fluid/operators/print_op.cc | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/paddle/fluid/operators/print_op.cc b/paddle/fluid/operators/print_op.cc index 2afd16110d5..3fb18365e52 100644 --- a/paddle/fluid/operators/print_op.cc +++ b/paddle/fluid/operators/print_op.cc @@ -73,18 +73,6 @@ class PrintOp : public framework::OperatorBase { int first_n = Attr("first_n"); if (first_n > 0 && ++times_ > first_n) return; - framework::LoDTensor printed_tensor; - printed_tensor.set_lod(in_tensor.lod()); - printed_tensor.Resize(in_tensor.dims()); - - if (is_cpu_place(in_tensor.place())) { - printed_tensor.ShareDataWith(in_tensor); - } else { - // copy data to cpu to print - platform::CPUPlace place; - TensorCopy(in_tensor, place, &printed_tensor); - } - TensorFormatter formatter; const std::string &name = Attr("print_tensor_name") ? printed_var_name : ""; @@ -93,7 +81,7 @@ class PrintOp : public framework::OperatorBase { formatter.SetPrintTensorLod(Attr("print_tensor_lod")); formatter.SetPrintTensorLayout(Attr("print_tensor_layout")); formatter.SetSummarize(static_cast(Attr("summarize"))); - formatter.Print(printed_tensor, name, Attr("message")); + formatter.Print(in_tensor, name, Attr("message")); } private: -- GitLab