diff --git a/.clang-tidy b/.clang-tidy index 7c7f85ee9c..12e89fb63d 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -10,6 +10,7 @@ Checks: ' clang-analyzer*, clang-diagnostic-missing-prototypes, cppcoreguidelines-init-variables, +cppcoreguidelines-special-member-functions, bugprone*, -bugprone-crtp-constructor-accessibility, -bugprone-easily-swappable-parameters, @@ -72,4 +73,8 @@ CheckOptions: - key: facebook-cuda-safe-kernel-call-check.HandlerName # This is PyTorch's handler; you may need to define your own value: C10_CUDA_KERNEL_LAUNCH_CHECK + - key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor + value: true + - key: cppcoreguidelines-special-member-functions.AllowImplicitlyDeletedCopyOrMove + value: true ... diff --git a/include/fbgemm/Fbgemm.h b/include/fbgemm/Fbgemm.h index dd373fab7c..cea268a62d 100644 --- a/include/fbgemm/Fbgemm.h +++ b/include/fbgemm/Fbgemm.h @@ -79,9 +79,9 @@ class PackMatrix { public: PackMatrix() = delete; // no default constructor PackMatrix(const PackMatrix&) = delete; // no copy - PackMatrix& operator==(const PackMatrix&) = delete; // no copy + PackMatrix& operator=(const PackMatrix&) = delete; // no copy PackMatrix(PackMatrix&&) = delete; // no move - PackMatrix& operator==(PackMatrix&& rhs) noexcept = delete; // no move + PackMatrix& operator=(PackMatrix&& rhs) noexcept = delete; // no move /** * @param rows total number of rows in the matrix @@ -515,11 +515,11 @@ class FBGEMM_API PackWeightMatrixForGConv { PackWeightMatrixForGConv() = delete; // no default constructor PackWeightMatrixForGConv(const PackWeightMatrixForGConv&) = delete; // no copy - PackWeightMatrixForGConv& operator==(const PackWeightMatrixForGConv&) = + PackWeightMatrixForGConv& operator=(const PackWeightMatrixForGConv&) = delete; // no copy PackWeightMatrixForGConv(PackWeightMatrixForGConv&&) = delete; // no move - PackWeightMatrixForGConv& operator==(PackWeightMatrixForGConv&&) = + PackWeightMatrixForGConv& operator=(PackWeightMatrixForGConv&&) = delete; // no move /** @@ -715,6 +715,11 @@ class FBGEMM_API PackAWithIm2Col bool b_symmetric = false, const BlockingFactors* params = nullptr); + PackAWithIm2Col(const PackAWithIm2Col&) = delete; + PackAWithIm2Col(PackAWithIm2Col&&) = delete; + PackAWithIm2Col& operator=(const PackAWithIm2Col&) = delete; + PackAWithIm2Col& operator=(PackAWithIm2Col&&) = delete; + /** * Activation matrices are not constant so cannot amortize the cost of * pre-packing. @@ -799,6 +804,11 @@ class FBGEMM_API PackAWithRowOffset final std::int32_t* row_offset = nullptr, const BlockingFactors* params = nullptr); + PackAWithRowOffset(const PackAWithRowOffset&) = delete; + PackAWithRowOffset(PackAWithRowOffset&&) = delete; + PackAWithRowOffset& operator=(const PackAWithRowOffset&) = delete; + PackAWithRowOffset& operator=(PackAWithRowOffset&&) = delete; + /** * Activation matrices are not constant so cannot amortize the cost of * pre-packing. @@ -890,6 +900,10 @@ class FBGEMM_API PackAWithQuantRowOffset final int groups = 1, std::int32_t* row_offset = nullptr, const BlockingFactors* params = nullptr); + PackAWithQuantRowOffset(const PackAWithQuantRowOffset&) = delete; + PackAWithQuantRowOffset(PackAWithQuantRowOffset&&) = delete; + PackAWithQuantRowOffset& operator=(const PackAWithQuantRowOffset&) = delete; + PackAWithQuantRowOffset& operator=(PackAWithQuantRowOffset&&) = delete; /** * Activation matrices are not constant so cannot amortize the cost of diff --git a/include/fbgemm/FbgemmI8DepthwiseAvx2.h b/include/fbgemm/FbgemmI8DepthwiseAvx2.h index 7f5e60fe70..ed55480ae7 100644 --- a/include/fbgemm/FbgemmI8DepthwiseAvx2.h +++ b/include/fbgemm/FbgemmI8DepthwiseAvx2.h @@ -8,7 +8,6 @@ #pragma once -#include #include #include "fbgemm/ConvUtils.h" #include "fbgemm/FbgemmBuild.h" @@ -27,6 +26,10 @@ class FBGEMM_API PackedDepthWiseConvMatrix { * @param smat the source unpacked weight in GRS layout */ PackedDepthWiseConvMatrix(int OC, int kernel_prod, const std::int8_t* smat); + PackedDepthWiseConvMatrix(const PackedDepthWiseConvMatrix&) = delete; + PackedDepthWiseConvMatrix(PackedDepthWiseConvMatrix&&) = delete; + PackedDepthWiseConvMatrix& operator=(const PackedDepthWiseConvMatrix&) = delete; + PackedDepthWiseConvMatrix& operator=(PackedDepthWiseConvMatrix&&) = delete; virtual ~PackedDepthWiseConvMatrix(); const std::int8_t* PackedMat() const { diff --git a/include/fbgemm/FbgemmI8DirectconvAvx2.h b/include/fbgemm/FbgemmI8DirectconvAvx2.h index 09fc9fcf17..2c2e8eb0bc 100644 --- a/include/fbgemm/FbgemmI8DirectconvAvx2.h +++ b/include/fbgemm/FbgemmI8DirectconvAvx2.h @@ -31,6 +31,11 @@ class FBGEMM_API PackedDirectConvMatrix { int OC_per_G, int filter_prod, const std::int8_t* smat); + PackedDirectConvMatrix(const PackedDirectConvMatrix&) = delete; + PackedDirectConvMatrix(PackedDirectConvMatrix&&) = delete; + PackedDirectConvMatrix& operator=(const PackedDirectConvMatrix&) = delete; + PackedDirectConvMatrix& operator=(PackedDirectConvMatrix&&) = delete; + virtual ~PackedDirectConvMatrix(); const std::int8_t* PackedMat() const { diff --git a/include/fbgemm/FbgemmPackMatrixB.h b/include/fbgemm/FbgemmPackMatrixB.h index c67a829ca3..a88b705ace 100644 --- a/include/fbgemm/FbgemmPackMatrixB.h +++ b/include/fbgemm/FbgemmPackMatrixB.h @@ -126,6 +126,10 @@ class PackedGemmMatrixB { packed_ = true; pmat_passed_in = true; } + PackedGemmMatrixB(const PackedGemmMatrixB&) = delete; + PackedGemmMatrixB(PackedGemmMatrixB&&) = delete; + PackedGemmMatrixB& operator=(const PackedGemmMatrixB&) = delete; + PackedGemmMatrixB& operator=(PackedGemmMatrixB&&) = delete; void initializeParam() { if (!cpuinfo_initialize()) {