From c8c2b9575dd62076018292fcc90e1f11bfc18f58 Mon Sep 17 00:00:00 2001 From: Eduard Valeyev Date: Wed, 24 Jul 2024 15:17:37 -0400 Subject: [PATCH] DeviceTensor's move ctro/assignment can just move buffer (?) --- examples/spmm/spmm_cuda.cc | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/examples/spmm/spmm_cuda.cc b/examples/spmm/spmm_cuda.cc index 2df91d147..0986c7ed8 100644 --- a/examples/spmm/spmm_cuda.cc +++ b/examples/spmm/spmm_cuda.cc @@ -192,12 +192,7 @@ struct DeviceTensor : public ttg::TTValue> DeviceTensor(DeviceTensor&& x) noexcept : ttvalue_type(std::move(x)) , tensor_type(static_cast(x)) - /* Grrrr, moving a Tensor does not guarantee to move the pointer */ - , b((this->size() == 0 || - this->data() == x.b.host_ptr()) ? std::move(x.b) - : ttg::Buffer<_T>(this->size() ? this->data() - : nullptr, - this->size())) + , b(std::move(x.b)) { assert(this->data() == b.host_ptr()); //std::cout << "DeviceTensor move ctor" << std::endl; @@ -238,12 +233,7 @@ struct DeviceTensor : public ttg::TTValue> DeviceTensor& operator=(DeviceTensor&& x) noexcept { ttvalue_type::operator=(std::move(x)); tensor_type::operator=(static_cast(x)); - if (this->size() == 0 || this->data() == x.b.host_ptr()){ - b = std::move(x.b); - } else { - b = ttg::Buffer<_T>(this->size() ? this->data() : nullptr, this->size()); - } - //std::swap(x.b, b); + b = std::move(x.b); //std::cout << "DeviceTensor move ctor" << std::endl; return *this; }