Skip to content

Commit 5b53f40

Browse files
[pre-commit.ci lite] apply automatic fixes
1 parent 4031e12 commit 5b53f40

File tree

1 file changed

+8
-4
lines changed
  • source/module_base/module_container/ATen/core

1 file changed

+8
-4
lines changed

source/module_base/module_container/ATen/core/tensor.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ Tensor::Tensor(Tensor&& other) noexcept
5353
// However, Our subclass TensorMap, etc., do not own resources.
5454
// So, we do not need to declare a virtual destructor here.
5555
Tensor::~Tensor() {
56-
if (buffer_) buffer_->unref();
56+
if (buffer_) { buffer_->unref();
57+
}
5758
}
5859

5960
// Get the data type of the tensor.
@@ -223,7 +224,8 @@ Tensor& Tensor::operator=(const Tensor& other) {
223224
this->device_ = other.device_;
224225
this->data_type_ = other.data_type_;
225226
this->shape_ = other.shape_;
226-
if (buffer_) buffer_->unref();
227+
if (buffer_) { buffer_->unref();
228+
}
227229

228230
this->buffer_ = new TensorBuffer(GetAllocator(device_), shape_.NumElements() * SizeOfType(data_type_));
229231

@@ -241,7 +243,8 @@ Tensor& Tensor::operator=(Tensor&& other) noexcept {
241243
this->data_type_ = other.data_type_;
242244
this->shape_ = other.shape_;
243245

244-
if (buffer_) buffer_->unref(); // Release current resource
246+
if (buffer_) { buffer_->unref(); // Release current resource
247+
}
245248
this->buffer_ = other.buffer_;
246249
other.buffer_ = nullptr; // Reset the other TensorBuffer.
247250
return *this;
@@ -284,7 +287,8 @@ bool Tensor::AllocateFrom(const Tensor& other, const TensorShape& shape) {
284287
data_type_ = other.data_type_;
285288
device_ = other.device_;
286289
shape_ = shape;
287-
if (buffer_) buffer_->unref();
290+
if (buffer_) { buffer_->unref();
291+
}
288292
buffer_ = new TensorBuffer(GetAllocator(device_), shape_.NumElements() * SizeOfType(data_type_));
289293
return true;
290294
}

0 commit comments

Comments
 (0)