From 2d91053c1abc047a0a8d8193eb68b0c41d1cef97 Mon Sep 17 00:00:00 2001 From: jim19930609 Date: Fri, 7 Jan 2022 02:29:26 +0000 Subject: [PATCH] Fixed LoD issues --- paddle/pten/core/dense_tensor.cc | 4 +--- paddle/pten/core/utils/intrusive_ptr.h | 3 +-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/paddle/pten/core/dense_tensor.cc b/paddle/pten/core/dense_tensor.cc index 841210ba95792..b09d7bee3f15e 100644 --- a/paddle/pten/core/dense_tensor.cc +++ b/paddle/pten/core/dense_tensor.cc @@ -233,7 +233,6 @@ DenseTensor::DenseTensor() { storage_ = make_intrusive( paddle::platform::CPUPlace()); inplace_version_counter_ = std::make_shared(0); - meta_ = DenseTensorMeta(); meta_.dtype = paddle::experimental::DataType::FLOAT32; meta_.offset = 0; } @@ -242,7 +241,6 @@ DenseTensor::DenseTensor(const paddle::framework::proto::VarType::Type& dtype) { storage_ = make_intrusive( paddle::platform::CPUPlace()); inplace_version_counter_ = std::make_shared(0); - meta_ = DenseTensorMeta(); meta_.dtype = TransToPtenDataType(dtype); meta_.offset = 0; } @@ -464,7 +462,7 @@ LEGACY_DATA_MEMBER_FUNC_INSTANTIATION(::paddle::experimental::complex128) /* From framework::LoDTensor */ /* ------------------------------ */ -DenseTensor::DenseTensor(const LoD& lod) : DenseTensor() { meta_.lod = lod; } +DenseTensor::DenseTensor(const LoD& lod) { meta_.lod = lod; } void DenseTensor::set_lod(const LoD& lod) { meta_.lod = lod; } diff --git a/paddle/pten/core/utils/intrusive_ptr.h b/paddle/pten/core/utils/intrusive_ptr.h index 99d5a1ccbc254..ed9a21e7f3a8a 100644 --- a/paddle/pten/core/utils/intrusive_ptr.h +++ b/paddle/pten/core/utils/intrusive_ptr.h @@ -41,8 +41,7 @@ class intrusive_ptr { } intrusive_ptr& operator=(intrusive_ptr&& rhs) { - px = rhs.px; - rhs.px = nullptr; + swap(rhs); return *this; }