mirror of
https://github.com/zebrajr/pytorch.git
synced 2026-01-15 12:15:51 +00:00
Apply more clang-tidy fixes (#169794)
This PR applies more clang-tidy fixes about readability and modernization. Pull Request resolved: https://github.com/pytorch/pytorch/pull/169794 Approved by: https://github.com/Skylion007
This commit is contained in:
committed by
PyTorch MergeBot
parent
3b0065bd9a
commit
e33fa0ece3
@@ -536,10 +536,10 @@ class DispatchKeySet final {
|
||||
using reference = value_type&;
|
||||
using pointer = value_type*;
|
||||
// final mask value should mask out the entire keyset
|
||||
static const uint8_t end_iter_mask_val =
|
||||
static constexpr uint8_t end_iter_mask_val =
|
||||
num_backends + num_functionality_keys;
|
||||
// final key value should be the last DispatchKey
|
||||
static const uint8_t end_iter_key_val = num_functionality_keys;
|
||||
static constexpr uint8_t end_iter_key_val = num_functionality_keys;
|
||||
|
||||
// current_dispatchkey_idx_ will iterate through all functionality bits.
|
||||
// current_backendcomponent_idx_ will iterate through all backend bits.
|
||||
@@ -549,11 +549,7 @@ class DispatchKeySet final {
|
||||
uint8_t next_backend = 0)
|
||||
: data_ptr_(data_ptr),
|
||||
next_functionality_(next_functionality),
|
||||
next_backend_(next_backend),
|
||||
// These are in an invalid state at construction time, and set by the
|
||||
// first increment call
|
||||
current_dispatchkey_idx_(end_iter_key_val),
|
||||
current_backendcomponent_idx_(end_iter_key_val) {
|
||||
next_backend_(next_backend) {
|
||||
// Go to the first key in the set
|
||||
TORCH_INTERNAL_ASSERT(
|
||||
next_functionality_ >= num_backends,
|
||||
@@ -615,8 +611,10 @@ class DispatchKeySet final {
|
||||
const uint64_t* data_ptr_;
|
||||
uint8_t next_functionality_;
|
||||
uint8_t next_backend_;
|
||||
uint8_t current_dispatchkey_idx_;
|
||||
uint8_t current_backendcomponent_idx_;
|
||||
// These are in an invalid state at construction time, and set by the
|
||||
// first increment call
|
||||
uint8_t current_dispatchkey_idx_{end_iter_key_val};
|
||||
uint8_t current_backendcomponent_idx_{end_iter_key_val};
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
@@ -105,11 +105,11 @@ struct C10_API StorageImpl : public c10::intrusive_ptr_target {
|
||||
data_ptr_.clear();
|
||||
}
|
||||
|
||||
void incref_pyobject() const noexcept override final;
|
||||
void incref_pyobject() const noexcept final;
|
||||
|
||||
void decref_pyobject() const noexcept override final;
|
||||
void decref_pyobject() const noexcept final;
|
||||
|
||||
bool try_incref_pyobject() const noexcept override final;
|
||||
bool try_incref_pyobject() const noexcept final;
|
||||
|
||||
size_t nbytes() const {
|
||||
// OK to do this instead of maybe_as_int as nbytes is guaranteed positive
|
||||
|
||||
@@ -2178,11 +2178,11 @@ struct C10_API TensorImpl : public c10::intrusive_ptr_target {
|
||||
return &pyobj_slot_;
|
||||
}
|
||||
|
||||
void incref_pyobject() const noexcept override final;
|
||||
void incref_pyobject() const noexcept final;
|
||||
|
||||
void decref_pyobject() const noexcept override final;
|
||||
void decref_pyobject() const noexcept final;
|
||||
|
||||
bool try_incref_pyobject() const noexcept override final;
|
||||
bool try_incref_pyobject() const noexcept final;
|
||||
|
||||
private:
|
||||
// See NOTE [std::optional operator usage in CUDA]
|
||||
|
||||
@@ -32,9 +32,7 @@
|
||||
* This header adds some polyfills with C++17 functionality
|
||||
*/
|
||||
|
||||
namespace c10 {
|
||||
|
||||
namespace guts {
|
||||
namespace c10::guts {
|
||||
|
||||
#if defined(__HIP__)
|
||||
|
||||
@@ -63,8 +61,6 @@ C10_HOST_DEVICE constexpr auto apply(F&& f, Tuple&& t) {
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace guts
|
||||
|
||||
} // namespace c10
|
||||
} // namespace c10::guts
|
||||
|
||||
#endif // C10_UTIL_CPP17_H_
|
||||
|
||||
@@ -815,8 +815,8 @@ class SmallVectorImpl : public SmallVectorTemplateBase<T> {
|
||||
iterator insert_one_impl(iterator I, ArgType&& Elt) {
|
||||
// Callers ensure that ArgType is derived from T.
|
||||
static_assert(
|
||||
std::is_same<std::remove_const_t<std::remove_reference_t<ArgType>>, T>::
|
||||
value,
|
||||
std::
|
||||
is_same_v<std::remove_const_t<std::remove_reference_t<ArgType>>, T>,
|
||||
"ArgType must be derived from T!");
|
||||
|
||||
if (I == this->end()) { // Important special case for empty vector.
|
||||
|
||||
@@ -391,25 +391,25 @@ namespace impl
|
||||
template <typename T>
|
||||
struct require_copy_constructible
|
||||
{
|
||||
static constexpr bool value = std::is_copy_constructible<underlying_type_t<T>>::value;
|
||||
static constexpr bool value = std::is_copy_constructible_v<underlying_type_t<T>>;
|
||||
static_assert(value, "underlying type must be copy constructible");
|
||||
};
|
||||
template <typename T>
|
||||
struct require_move_constructible
|
||||
{
|
||||
static constexpr bool value = std::is_move_constructible<underlying_type_t<T>>::value;
|
||||
static constexpr bool value = std::is_move_constructible_v<underlying_type_t<T>>;
|
||||
static_assert(value, "underlying type must be move constructible");
|
||||
};
|
||||
template <typename T>
|
||||
struct require_copy_assignable
|
||||
{
|
||||
static constexpr bool value = std::is_copy_assignable<underlying_type_t<T>>::value;
|
||||
static constexpr bool value = std::is_copy_assignable_v<underlying_type_t<T>>;
|
||||
static_assert(value, "underlying type must be copy assignable");
|
||||
};
|
||||
template <typename T>
|
||||
struct require_move_assignable
|
||||
{
|
||||
static constexpr bool value = std::is_move_assignable<underlying_type_t<T>>::value;
|
||||
static constexpr bool value = std::is_move_assignable_v<underlying_type_t<T>>;
|
||||
static_assert(value, "underlying type must be move assignable");
|
||||
};
|
||||
|
||||
@@ -820,7 +820,7 @@ class affine_point<D>::modifier<::strong::type<T, Tag, M...>>
|
||||
using base_diff_type = decltype(std::declval<const T&>() - std::declval<const T&>());
|
||||
public:
|
||||
using difference = std::conditional_t<std::is_same<D, void>{}, strong::type<base_diff_type, Tag, strong::difference>, D>;
|
||||
static_assert(std::is_constructible_v<difference, base_diff_type>, "");
|
||||
static_assert(std::is_constructible_v<difference, base_diff_type> );
|
||||
[[nodiscard]]
|
||||
friend
|
||||
constexpr
|
||||
@@ -1584,12 +1584,12 @@ namespace std {
|
||||
template <typename T, typename Tag, typename ... M>
|
||||
struct hash<::strong::type<T, Tag, M...>>
|
||||
: std::conditional_t<
|
||||
std::is_base_of<
|
||||
std::is_base_of_v<
|
||||
::strong::hashable::modifier<
|
||||
::strong::type<T, Tag, M...>
|
||||
>,
|
||||
::strong::type<T, Tag, M...>
|
||||
>::value,
|
||||
>,
|
||||
hash<T>,
|
||||
std::false_type>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user