Skip to content

Commit

Permalink
Enable readability-redundant-smartptr-get in clang-tidy (pytorch#116381)
Browse files Browse the repository at this point in the history
Pull Request resolved: pytorch#116381
Approved by: https://github.com/Skylion007
  • Loading branch information
cyyever authored and pytorchmergebot committed Dec 26, 2023
1 parent ffe6f9a commit bb2a1e9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
1 change: 1 addition & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ readability-container-size-empty,
readability-delete-null-pointer,
readability-duplicate-include
readability-misplaced-array-index,
readability-redundant-smartptr-get,
readability-string-compare,
'
HeaderFilterRegex: '^(aten/|c10/|torch/).*$'
Expand Down
10 changes: 5 additions & 5 deletions c10/core/Storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ struct C10_API Storage {

// TODO: remove later
void set_nbytes(size_t size_bytes) const {
storage_impl_.get()->set_nbytes(size_bytes);
storage_impl_->set_nbytes(size_bytes);
}

void set_nbytes(c10::SymInt size_bytes) const {
storage_impl_.get()->set_nbytes(std::move(size_bytes));
storage_impl_->set_nbytes(std::move(size_bytes));
}

bool resizable() const {
Expand Down Expand Up @@ -129,19 +129,19 @@ struct C10_API Storage {

// Returns the previous data_ptr
at::DataPtr set_data_ptr(at::DataPtr&& data_ptr) const {
return storage_impl_.get()->set_data_ptr(std::move(data_ptr));
return storage_impl_->set_data_ptr(std::move(data_ptr));
}

void set_data_ptr_noswap(at::DataPtr&& data_ptr) const {
return storage_impl_.get()->set_data_ptr_noswap(std::move(data_ptr));
return storage_impl_->set_data_ptr_noswap(std::move(data_ptr));
}

DeviceType device_type() const {
return storage_impl_->device_type();
}

at::Allocator* allocator() const {
return storage_impl_.get()->allocator();
return storage_impl_->allocator();
}

at::Device device() const {
Expand Down
4 changes: 1 addition & 3 deletions torch/csrc/autograd/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,9 @@
#include <memory>
#include <mutex>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <thread>
#include <typeinfo>
#include <unordered_set>
#include <utility>

Expand Down Expand Up @@ -1120,7 +1118,7 @@ inline static uint64_t compute_min_topological_nr(const edge_list& outputs) {
}
auto min_topo_nr = std::numeric_limits<uint64_t>::max();
for (auto& output_edge : outputs) {
auto topo_nr = output_edge.function.get()->topological_nr();
auto topo_nr = output_edge.function->topological_nr();
min_topo_nr = (min_topo_nr < topo_nr) ? min_topo_nr : topo_nr;
}
return min_topo_nr;
Expand Down

0 comments on commit bb2a1e9

Please sign in to comment.