Skip to content

Commit 2982046

Browse files
authored
remove useless move (#55430)
1 parent 0756793 commit 2982046

File tree

2 files changed

+16
-18
lines changed

2 files changed

+16
-18
lines changed

paddle/fluid/eager/tensor_wrapper.h

+6-8
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,9 @@ class TensorWrapper {
6363
static_cast<phi::DenseTensor*>(tensor.impl().get());
6464
// TODO(jiabin): It's not a good idea to set memory size to zero, find
6565
// another way and change this.
66-
intermidiate_tensor_.set_impl(
67-
std::move(std::make_shared<phi::DenseTensor>(
68-
std::make_shared<phi::Allocation>(nullptr, 0, tensor.place()),
69-
std::move(dense_tensor->meta()))));
66+
intermidiate_tensor_.set_impl(std::make_shared<phi::DenseTensor>(
67+
std::make_shared<phi::Allocation>(nullptr, 0, tensor.place()),
68+
dense_tensor->meta()));
7069
} else {
7170
PADDLE_THROW(paddle::platform::errors::Fatal(
7271
"Unrecognized tensor type for no_need_buffer feature"));
@@ -77,10 +76,9 @@ class TensorWrapper {
7776
tensor.is_dense_tensor() && tensor.initialized()) {
7877
phi::DenseTensor* dense_tensor =
7978
static_cast<phi::DenseTensor*>(tensor.impl().get());
80-
intermidiate_tensor_.set_impl(
81-
std::move(std::make_shared<phi::DenseTensor>(
82-
std::make_shared<phi::Allocation>(nullptr, 0, tensor.place()),
83-
dense_tensor->meta())));
79+
intermidiate_tensor_.set_impl(std::make_shared<phi::DenseTensor>(
80+
std::make_shared<phi::Allocation>(nullptr, 0, tensor.place()),
81+
dense_tensor->meta()));
8482
auto pack_hook = egr::SavedTensorsHooks::GetInstance().GetPackHook();
8583
unpack_hook_ = egr::SavedTensorsHooks::GetInstance().GetUnPackHook();
8684
packed_value_ = (*pack_hook)(tensor);

paddle/phi/api/lib/tensor.cc

+10-10
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ Tensor::Tensor(const Place &place) {
6464
"the `place`, and datatype, shape, layout, etc. is also "
6565
"required.";
6666
DefaultAllocator alloc(place);
67-
impl_ = std::move(std::make_shared<phi::DenseTensor>(
67+
impl_ = std::make_shared<phi::DenseTensor>(
6868
&alloc,
69-
std::move(phi::DenseTensorMeta(
70-
phi::DataType::FLOAT32, phi::make_ddim({}), phi::DataLayout::NCHW))));
69+
phi::DenseTensorMeta(
70+
phi::DataType::FLOAT32, phi::make_ddim({}), phi::DataLayout::NCHW));
7171
}
7272

7373
Tensor::Tensor(const Place &place, const std::vector<int64_t> &shape) {
@@ -80,11 +80,11 @@ Tensor::Tensor(const Place &place, const std::vector<int64_t> &shape) {
8080
"the `place` and `shape`, and datatype, layout, etc. is also "
8181
"required.";
8282
DefaultAllocator alloc(place);
83-
impl_ = std::move(std::make_shared<phi::DenseTensor>(
83+
impl_ = std::make_shared<phi::DenseTensor>(
8484
&alloc,
85-
std::move(phi::DenseTensorMeta(phi::DataType::FLOAT32,
86-
phi::make_ddim({shape}),
87-
phi::DataLayout::NCHW))));
85+
phi::DenseTensorMeta(phi::DataType::FLOAT32,
86+
phi::make_ddim({shape}),
87+
phi::DataLayout::NCHW));
8888
}
8989

9090
Tensor::Tensor(std::shared_ptr<phi::TensorBase> tensor_impl,
@@ -338,11 +338,11 @@ void *Tensor::data() {
338338
// TODO(chenweihang): replace slice impl by API
339339
Tensor Tensor::slice(int64_t begin_idx, int64_t end_idx) const {
340340
if (is_dense_tensor()) {
341-
return Tensor(std::make_shared<phi::DenseTensor>(
342-
std::move(phi::DenseTensorUtils::Slice(
341+
return Tensor(
342+
std::make_shared<phi::DenseTensor>(phi::DenseTensorUtils::Slice(
343343
*(static_cast<phi::DenseTensor *>(impl_.get())),
344344
begin_idx,
345-
end_idx))));
345+
end_idx)));
346346
} else {
347347
PADDLE_THROW(phi::errors::Unimplemented(
348348
"Only support slice operation on DenseTensor now."));

0 commit comments

Comments
 (0)