Skip to content

Commit

Permalink
Revert "Enable cppcoreguidelines-special-member-functions (pytorch#13…
Browse files Browse the repository at this point in the history
…9132)"

This reverts commit a9b4989.

Reverted pytorch#139132 on behalf of https://github.com/ZainRizvi due to Sorry but this fails on trunk. See inductor/test_mkldnn_pattern_matcher.py::TestPatternMatcher::test_smooth_quant_with_int_mm [GH job link](https://github.com/pytorch/pytorch/actions/runs/11699366379/job/32591132460) [HUD commit link](https://hud.pytorch.org/pytorch/pytorch/commit/22e89ea2aaa3e0ef0ec4504bd2dbf230447a6d2a) ([comment](pytorch#139132 (comment)))
  • Loading branch information
pytorchmergebot committed Nov 6, 2024
1 parent 06ad404 commit 10d7729
Show file tree
Hide file tree
Showing 42 changed files with 12 additions and 130 deletions.
3 changes: 1 addition & 2 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ cppcoreguidelines-*,
-cppcoreguidelines-pro-type-static-cast-downcast,
-cppcoreguidelines-pro-type-union-access,
-cppcoreguidelines-pro-type-vararg,
-cppcoreguidelines-special-member-functions,
-cppcoreguidelines-non-private-member-variables-in-classes,
-facebook-hte-RelativeInclude,
hicpp-exception-baseclass,
Expand Down Expand Up @@ -63,7 +64,5 @@ readability-string-compare,
HeaderFilterRegex: '^(aten/|c10/|torch/).*$'
WarningsAsErrors: '*'
CheckOptions:
cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor: true
cppcoreguidelines-special-member-functions.AllowImplicitlyDeletedCopyOrMove: true
misc-header-include-cycle.IgnoredFilesList: 'format.h;ivalue.h;custom_class.h;Dict.h;List.h;IListRef.h'
...
8 changes: 0 additions & 8 deletions aten/src/ATen/Context.h
Original file line number Diff line number Diff line change
Expand Up @@ -604,10 +604,6 @@ inline void manual_seed(uint64_t seed) {
// NoTF32Guard disable_tf32;
struct TORCH_API NoTF32Guard {
NoTF32Guard();
NoTF32Guard(NoTF32Guard&& other) = delete;
NoTF32Guard(const NoTF32Guard&) = delete;
NoTF32Guard& operator=(const NoTF32Guard&) = delete;
NoTF32Guard& operator=(NoTF32Guard&&) = delete;
~NoTF32Guard();
static bool should_disable_tf32();

Expand All @@ -617,10 +613,6 @@ struct TORCH_API NoTF32Guard {

struct TORCH_API ROCmBackwardPassGuard {
ROCmBackwardPassGuard();
ROCmBackwardPassGuard(ROCmBackwardPassGuard&& other) = delete;
ROCmBackwardPassGuard(const ROCmBackwardPassGuard&) = delete;
ROCmBackwardPassGuard& operator=(const ROCmBackwardPassGuard&) = delete;
ROCmBackwardPassGuard& operator=(ROCmBackwardPassGuard&&) = delete;
~ROCmBackwardPassGuard();
static bool is_backward_pass();
};
Expand Down
2 changes: 0 additions & 2 deletions aten/src/ATen/DynamicLibrary.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ namespace at {

struct DynamicLibrary {
AT_DISALLOW_COPY_AND_ASSIGN(DynamicLibrary);
DynamicLibrary(DynamicLibrary&& other) = delete;
DynamicLibrary& operator=(DynamicLibrary&&) = delete;

TORCH_API DynamicLibrary(
const char* name,
Expand Down
6 changes: 0 additions & 6 deletions aten/src/ATen/SparseCsrTensorUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,6 @@ class CheckSparseTensorInvariants {
: old_state(at::globalContext().checkSparseTensorInvariants()) {
at::globalContext().setCheckSparseTensorInvariants(state);
}
CheckSparseTensorInvariants(CheckSparseTensorInvariants&& other) = delete;
CheckSparseTensorInvariants(const CheckSparseTensorInvariants&) = delete;
CheckSparseTensorInvariants& operator=(const CheckSparseTensorInvariants&) =
delete;
CheckSparseTensorInvariants& operator=(CheckSparseTensorInvariants&&) =
delete;

~CheckSparseTensorInvariants() {
at::globalContext().setCheckSparseTensorInvariants(old_state);
Expand Down
1 change: 0 additions & 1 deletion aten/src/ATen/TensorIterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,6 @@ class TORCH_API TensorIteratorConfig final {
/// TensorIterator that can use 32-bit indexing. Taken together the splits cover
/// the original TensorIterator.
struct TORCH_API SplitUntil32Bit {
// NOLINTNEXTLINE(cppcoreguidelines-special-member-functions)
struct TORCH_API iterator {
iterator() = default;
iterator(const TensorIteratorBase& iter);
Expand Down
4 changes: 0 additions & 4 deletions aten/src/ATen/ThreadLocalState.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,6 @@ class TORCH_API ThreadLocalStateGuard {
// set the given state across the thread boundary
ThreadLocalState::setThreadLocalState(state);
}
ThreadLocalStateGuard(ThreadLocalStateGuard&& other) = delete;
ThreadLocalStateGuard(const ThreadLocalStateGuard&) = delete;
ThreadLocalStateGuard& operator=(const ThreadLocalStateGuard&) = delete;
ThreadLocalStateGuard& operator=(ThreadLocalStateGuard&&) = delete;

~ThreadLocalStateGuard() {
// restore previously set variables
Expand Down
1 change: 0 additions & 1 deletion aten/src/ATen/core/Dict.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ template<class Key, class Value> Dict<IValue, IValue> toGenericDict(Dict<Key, Va
* for the kernel API.
*/
template<class Key, class Value>
// NOLINTNEXTLINE(cppcoreguidelines-special-member-functions)
class Dict final {
private:
static_assert((std::is_same_v<IValue, Key> && std::is_same_v<IValue, Value>) || guts::typelist::contains<impl::valid_dict_key_types, Key>::value, "Invalid Key type for Dict. We only support int64_t, double, bool, and string.");
Expand Down
8 changes: 0 additions & 8 deletions aten/src/ATen/core/PythonFallbackKernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ namespace at::impl {

struct TORCH_API RestorePythonTLSSnapshot {
RestorePythonTLSSnapshot();
RestorePythonTLSSnapshot(RestorePythonTLSSnapshot&& other) = delete;
RestorePythonTLSSnapshot(const RestorePythonTLSSnapshot&) = delete;
RestorePythonTLSSnapshot& operator=(const RestorePythonTLSSnapshot&) = delete;
RestorePythonTLSSnapshot& operator=(RestorePythonTLSSnapshot&&) = delete;
~RestorePythonTLSSnapshot();

private:
Expand All @@ -22,10 +18,6 @@ struct TORCH_API RestorePythonTLSSnapshot {
struct TORCH_API MaybeSetTLSOnEntryGuard {
public:
MaybeSetTLSOnEntryGuard();
MaybeSetTLSOnEntryGuard(MaybeSetTLSOnEntryGuard&& other) = delete;
MaybeSetTLSOnEntryGuard(const MaybeSetTLSOnEntryGuard&) = delete;
MaybeSetTLSOnEntryGuard& operator=(const MaybeSetTLSOnEntryGuard&) = delete;
MaybeSetTLSOnEntryGuard& operator=(MaybeSetTLSOnEntryGuard&&) = delete;
~MaybeSetTLSOnEntryGuard();

private:
Expand Down
2 changes: 1 addition & 1 deletion aten/src/ATen/core/QuantizerBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct TORCH_API Quantizer : public c10::intrusive_ptr_target {
// NOLINTNEXTLINE(cppcoreguidelines-avoid-const-or-ref-data-members)
const ScalarType scalar_type_;
explicit Quantizer(ScalarType scalar_type) : scalar_type_(scalar_type) {}
~Quantizer() override = default;
~Quantizer() override;

// Copied from torch/csrc/jit/ir/scope.h
QuantizerPtr intrusive_from_this() {
Expand Down
6 changes: 0 additions & 6 deletions aten/src/ATen/core/Tensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include <c10/util/Exception.h>

namespace at {
// NOLINTNEXTLINE(cppcoreguidelines-special-member-functions)
class TORCH_API OptionalTensorRef {
public:
OptionalTensorRef() = default;
Expand All @@ -21,7 +20,6 @@ class TORCH_API OptionalTensorRef {
OptionalTensorRef(const OptionalTensorRef& rhs)
: ref_(Tensor::unsafe_borrow_t{}, rhs.ref_) {}

OptionalTensorRef(OptionalTensorRef&& rhs) = default;
OptionalTensorRef& operator=(OptionalTensorRef rhs) {
std::swap(ref_, rhs.ref_);
return *this;
Expand Down Expand Up @@ -61,10 +59,6 @@ class TORCH_API TensorRef {

TensorRef(const TensorBase& src)
: ref_(Tensor::unsafe_borrow_t{}, src) {}
TensorRef(TensorRef&& other) = default;
TensorRef(const TensorRef&) = default;
TensorRef& operator=(const TensorRef&) = default;
TensorRef& operator=(TensorRef&&) = default;

const Tensor& operator*() const & {
return ref_;
Expand Down
3 changes: 0 additions & 3 deletions aten/src/ATen/core/Vitals.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ struct TORCH_API TorchVital {
explicit TorchVital(std::string n) : name(std::move(n)) {}
TorchVital(const TorchVital&) = default;
TorchVital(TorchVital&&) = default;
TorchVital& operator=(const TorchVital&) = default;
TorchVital& operator=(TorchVital&&) = default;
TorchVital() = delete;

TorchVitalAttr& create(const std::string& attr);
Expand Down Expand Up @@ -73,7 +71,6 @@ class TORCH_API APIVitals {
APIVitals(APIVitals&& other) = delete;
APIVitals& operator=(const APIVitals&) = delete;
APIVitals& operator=(APIVitals&&) = delete;
~APIVitals() = default;

private:
std::unordered_map<std::string, TorchVital> name_map_;
Expand Down
5 changes: 0 additions & 5 deletions aten/src/ATen/core/dynamic_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,6 @@ class DynamicType : public SharedType {
explicit DynamicType(Tag, Arguments);
explicit DynamicType(Tag, std::string_view, Arguments);

DynamicType(DynamicType&& other) = delete;
DynamicType(const DynamicType&) = delete;
DynamicType& operator=(const DynamicType&) = delete;
DynamicType& operator=(DynamicType&&) = delete;

TypePtr containedType(size_t) const override;
size_t containedTypeSize() const override;
Tag tag() const {
Expand Down
2 changes: 1 addition & 1 deletion aten/src/ATen/core/jit_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -2204,7 +2204,7 @@ struct TORCH_API InterfaceType : public NamedType {
return is_module_;
}
static const TypeKind Kind = TypeKind::InterfaceType;
~InterfaceType() override = default;
~InterfaceType() override;
private:
InterfaceType(QualifiedName name, bool is_module);
static bool isSubTypeImpl(
Expand Down
1 change: 0 additions & 1 deletion aten/src/ATen/core/jit_type_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ struct TORCH_API Type {
SingletonOrSharedTypePtr(SingletonOrSharedTypePtr&&) noexcept = default;
SingletonOrSharedTypePtr& operator=(const SingletonOrSharedTypePtr&) = default;
SingletonOrSharedTypePtr& operator=(SingletonOrSharedTypePtr&&) noexcept = default;
~SingletonOrSharedTypePtr() = default;

T* get() const {
return repr_.isSharedAndNonNull() ? repr_.shared_.repr_.get() : static_cast<T*>(repr_.rawRepr().first);
Expand Down
1 change: 0 additions & 1 deletion aten/src/ATen/core/rref_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class C10_EXPORT RRefInterface : public c10::intrusive_ptr_target {
// counting.
RRefInterface(const RRefInterface& other) = delete;
RRefInterface(RRefInterface&& other) = delete;
RRefInterface& operator=(const RRefInterface& other) = delete;
RRefInterface& operator=(RRefInterface&& other) = delete;

~RRefInterface() override = default;
Expand Down
2 changes: 2 additions & 0 deletions aten/src/ATen/core/type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,8 @@ InterfaceType::InterfaceType(QualifiedName name, bool is_module)
methods_(std::make_shared<std::vector<FunctionSchema>>()),
is_module_(is_module) {}

InterfaceType::~InterfaceType() = default;

bool containsAnyType(const TypePtr& type) {
std::vector<TypePtr> to_scan = { type };
while (!to_scan.empty()) {
Expand Down
6 changes: 0 additions & 6 deletions aten/src/ATen/functorch/DynamicLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,6 @@ struct SaveLocalDispatchKeySet {
}
SaveLocalDispatchKeySet(const SaveLocalDispatchKeySet&) = delete;
SaveLocalDispatchKeySet& operator=(const SaveLocalDispatchKeySet&) = delete;
SaveLocalDispatchKeySet(SaveLocalDispatchKeySet&&) = delete;
SaveLocalDispatchKeySet& operator=(SaveLocalDispatchKeySet&&) = delete;
};

const std::vector<DynamicLayer>& getDynamicLayerStack() {
Expand Down Expand Up @@ -408,10 +406,6 @@ static void dump_local_tls() {

struct WithoutTop {
WithoutTop();
WithoutTop(WithoutTop&& other) = delete;
WithoutTop(const WithoutTop&) = delete;
WithoutTop& operator=(const WithoutTop&) = delete;
WithoutTop& operator=(WithoutTop&&) = delete;
~WithoutTop();
DynamicLayer layer_;
};
Expand Down
2 changes: 2 additions & 0 deletions aten/src/ATen/quantized/Quantizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ Tensor& PerChannelAffineFloatQParamsQuantizer::dequantize_out(
return rtensor;
}

Quantizer::~Quantizer() = default;

C10_EXPORT void set_quantizer_(const Tensor& self, ConstQuantizerPtr quantizer) {
get_qtensorimpl(self)->set_quantizer_(quantizer);
}
Expand Down
6 changes: 0 additions & 6 deletions aten/src/ATen/record_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,6 @@ struct TORCH_API RecordFunction {

RecordFunction(const RecordFunction&) = delete;
RecordFunction& operator=(const RecordFunction&) = delete;
RecordFunction(RecordFunction&&) = delete;
RecordFunction& operator=(RecordFunction&&) = delete;

const char* name() const;

Expand Down Expand Up @@ -766,10 +764,6 @@ class TORCH_API RecordFunctionGuard {
enableRecordFunction(is_enabled);
}

RecordFunctionGuard(RecordFunctionGuard&& other) = delete;
RecordFunctionGuard(const RecordFunctionGuard&) = delete;
RecordFunctionGuard& operator=(const RecordFunctionGuard&) = delete;
RecordFunctionGuard& operator=(RecordFunctionGuard&&) = delete;
virtual ~RecordFunctionGuard() {
enableRecordFunction(prev_value_);
}
Expand Down
4 changes: 0 additions & 4 deletions c10/core/impl/PythonDispatcherTLS.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ struct C10_API DisablePythonDispatcher {
PythonDispatcherTLS::set_state({});
}

DisablePythonDispatcher(DisablePythonDispatcher&& other) = delete;
DisablePythonDispatcher(const DisablePythonDispatcher&) = delete;
DisablePythonDispatcher& operator=(const DisablePythonDispatcher&) = delete;
DisablePythonDispatcher& operator=(DisablePythonDispatcher&&) = delete;
~DisablePythonDispatcher() {
PythonDispatcherTLS::set_state(old_);
}
Expand Down
4 changes: 2 additions & 2 deletions c10/test/util/Metaprogramming_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

using namespace c10::guts;

// NOLINTBEGIN(modernize*, cppcoreguidelines-special-member-functions)
// NOLINTBEGIN(modernize*)
namespace {

namespace test_function_traits {
Expand Down Expand Up @@ -302,4 +302,4 @@ TEST(MetaprogrammingTest, TupleMap_canBeUsedWithAutoLambdas) {
} // namespace test_tuple_map

} // namespace
// NOLINTEND(modernize*, cppcoreguidelines-special-member-functions)
// NOLINTEND(modernize*)
2 changes: 0 additions & 2 deletions c10/test/util/ThreadLocal_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ TEST(ThreadLocalTest, TestThreadWithGlobalScopeVar) {
TEST(ThreadLocalTest, TestObjectsAreReleased) {
static std::atomic<int> ctors{0};
static std::atomic<int> dtors{0};
// NOLINTNEXTLINE(cppcoreguidelines-special-member-functions)
struct A {
A() {
++ctors;
Expand Down Expand Up @@ -184,7 +183,6 @@ TEST(ThreadLocalTest, TestObjectsAreReleased) {
TEST(ThreadLocalTest, TestObjectsAreReleasedByNonstaticThreadLocal) {
static std::atomic<int> ctors(0);
static std::atomic<int> dtors(0);
// NOLINTNEXTLINE(cppcoreguidelines-special-member-functions)
struct A {
A() {
++ctors;
Expand Down
1 change: 0 additions & 1 deletion c10/test/util/intrusive_ptr_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ struct SomeChildClass : SomeBaseClass {
SomeChildClass(int v) : SomeBaseClass(v) {}
};

// NOLINTNEXTLINE(cppcoreguidelines-special-member-functions)
class DestructableMock : public intrusive_ptr_target {
public:
DestructableMock(bool* resourcesReleased, bool* wasDestructed)
Expand Down
1 change: 0 additions & 1 deletion c10/test/util/logging_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ TEST(
}

namespace {
// NOLINTNEXTLINE(cppcoreguidelines-special-member-functions)
struct Noncopyable {
int x;

Expand Down
2 changes: 0 additions & 2 deletions c10/test/util/typeid_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ TEST(TypeMetaTest, TypeMeta) {
EXPECT_NE(bar_meta.name().find("TypeMetaTestBar"), c10::string_view::npos);
}

// NOLINTNEXTLINE(cppcoreguidelines-special-member-functions)
class ClassAllowAssignment {
public:
ClassAllowAssignment() = default;
Expand All @@ -79,7 +78,6 @@ class ClassAllowAssignment {
int x{42};
};

// NOLINTNEXTLINE(cppcoreguidelines-special-member-functions)
class ClassNoAssignment {
public:
ClassNoAssignment() = default;
Expand Down
5 changes: 0 additions & 5 deletions c10/util/DynamicCounter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ struct DynamicCounter::Guard {
}
}

Guard(Guard&& other) = delete;
Guard(const Guard&) = delete;
Guard& operator=(const Guard&) = delete;
Guard& operator=(Guard&&) = delete;

~Guard() {
for (const auto& backend : backends_) {
backend->unregisterCounter(key_);
Expand Down
4 changes: 0 additions & 4 deletions c10/util/Exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,6 @@ class C10_API WarningHandlerGuard {
: prev_handler_(c10::WarningUtils::get_warning_handler()) {
c10::WarningUtils::set_warning_handler(new_handler);
}
WarningHandlerGuard(WarningHandlerGuard&& other) = delete;
WarningHandlerGuard(const WarningHandlerGuard&) = delete;
WarningHandlerGuard& operator=(const WarningHandlerGuard&) = delete;
WarningHandlerGuard& operator=(WarningHandlerGuard&&) = delete;
~WarningHandlerGuard() {
c10::WarningUtils::set_warning_handler(prev_handler_);
}
Expand Down
3 changes: 0 additions & 3 deletions c10/util/LeftRight.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ struct IncrementRAII final {
~IncrementRAII() {
_counter->fetch_sub(1);
}
IncrementRAII(IncrementRAII&&) = delete;
IncrementRAII& operator=(IncrementRAII&&) = delete;

private:
std::atomic<int32_t>* _counter;
Expand Down Expand Up @@ -203,7 +201,6 @@ class RWSafeLeftRightWrapper final {
RWSafeLeftRightWrapper(RWSafeLeftRightWrapper&&) noexcept = delete;
RWSafeLeftRightWrapper& operator=(const RWSafeLeftRightWrapper&) = delete;
RWSafeLeftRightWrapper& operator=(RWSafeLeftRightWrapper&&) noexcept = delete;
~RWSafeLeftRightWrapper() = default;

template <typename F>
// NOLINTNEXTLINE(cppcoreguidelines-missing-std-forward)
Expand Down
1 change: 0 additions & 1 deletion c10/util/order_preserving_flat_hash_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ struct KeyOrValueEquality : functor_storage<bool, key_equal> {
};
static constexpr int8_t min_lookups = 4;
template <typename T>
// NOLINTNEXTLINE(cppcoreguidelines-special-member-functions)
struct sherwood_v3_entry {
// NOLINTNEXTLINE(modernize-use-equals-default)
sherwood_v3_entry() {}
Expand Down
4 changes: 0 additions & 4 deletions torch/csrc/distributed/rpc/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ TORCH_API void disableJitRRefPickle();

struct TORCH_API JitRRefPickleGuard {
JitRRefPickleGuard();
JitRRefPickleGuard(JitRRefPickleGuard&& other) = delete;
JitRRefPickleGuard(const JitRRefPickleGuard&) = delete;
JitRRefPickleGuard& operator=(const JitRRefPickleGuard&) = delete;
JitRRefPickleGuard& operator=(JitRRefPickleGuard&&) = delete;
~JitRRefPickleGuard();
};

Expand Down
Loading

0 comments on commit 10d7729

Please sign in to comment.