diff --git a/paddle/fluid/operators/reshape_op.cc b/paddle/fluid/operators/reshape_op.cc index a796821729fb28006e20f1215ea1fa8faac8885f..856f4020cfcf6b5c711554e98370b837ef1f74d6 100644 --- a/paddle/fluid/operators/reshape_op.cc +++ b/paddle/fluid/operators/reshape_op.cc @@ -392,7 +392,9 @@ class ReshapeKernel { ctx.GetPlace()), std::move(meta)); pten::DenseTensor *pt_out = nullptr; - if (in == out) { + if (in != nullptr && out != nullptr && in->Holder() != nullptr && + out->Holder() != nullptr && + in->Holder()->ptr() == out->Holder()->ptr()) { pt_out = pt_x.get(); } else { pt_out = pt_out_tmp.get();