diff --git a/paddle/fluid/operators/print_op.cc b/paddle/fluid/operators/print_op.cc index 2afd16110d5d8723aeed13e8c3a89769f1d531de..3fb18365e523d75f5c3e6107011d2aac5a152dea 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: