Skip to content

Commit a9b0a92

Browse files
malfetfacebook-github-bot
authored andcommitted
Disable avoid-non-const-global-variables lint check (pytorch#62008)
Summary: As GoogleTest `TEST` macro is non-compliant with it as well as `DEFINE_DISPATCH` All changes but the ones to `.clang-tidy` are generated using following script: ``` for i in `find . -type f -iname "*.c*" -or -iname "*.h"|xargs grep cppcoreguidelines-avoid-non-const-global-variables|cut -f1 -d:|sort|uniq`; do sed -i "/\/\/ NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)/d" $i; done ``` Pull Request resolved: pytorch#62008 Reviewed By: driazati, r-barnes Differential Revision: D29838584 Pulled By: malfet fbshipit-source-id: 1b2f8602c945bd4ce50a9bfdd204755556e31d13
1 parent 260198d commit a9b0a92

File tree

1,011 files changed

+1
-7626
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,011 files changed

+1
-7626
lines changed

Diff for: .clang-tidy-oss

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ bugprone-*,
99
-bugprone-reserved-identifier,
1010
cppcoreguidelines-*,
1111
-cppcoreguidelines-avoid-magic-numbers,
12+
-cppcoreguidelines-avoid-non-const-global-variables,
1213
-cppcoreguidelines-interfaces-global-init,
1314
-cppcoreguidelines-macro-usage,
1415
-cppcoreguidelines-owning-memory,

Diff for: aten/src/ATen/Context.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,6 @@ Allocator* getCPUAllocator() {
235235
// means the allow_tf32 flags are overrided and tf32 is force disabled
236236
// override_allow_tf32_flag = false
237237
// means the original allow_tf32 flags are followed
238-
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
239238
thread_local bool override_allow_tf32_flag = false;
240239

241240
NoTF32Guard::NoTF32Guard() {

Diff for: aten/src/ATen/MapAllocator.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ struct MapInfo {
5353
std::atomic<int> refcount;
5454
};
5555

56-
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
5756
const std::string unknown_filename = "filename not specified";
5857
#ifdef _WIN32
5958
const std::string unknown_eventname = "eventname not specified";

Diff for: aten/src/ATen/ParallelNative.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,9 @@ namespace at {
2323
namespace {
2424
// used with _set_in_parallel_region to mark master thread
2525
// as in parallel region while executing parallel primitives
26-
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
2726
thread_local bool in_parallel_region_ = false;
2827

2928
// thread number (task_id) set by parallel primitive
30-
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
3129
thread_local int thread_num_ = 0;
3230

3331
void _set_in_parallel_region(bool in_region) {
@@ -60,7 +58,6 @@ const int CONSUMED = -2;
6058
// - NOT_SET - pool not initialized, user value is not set
6159
// - positive value - pool not initialized, user value set
6260
// - CONSUMED - pool is initialized
63-
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
6461
std::atomic<int> num_intraop_threads{NOT_SET};
6562

6663
int _num_pool_threads(int nthreads) {

Diff for: aten/src/ATen/ParallelThreadPoolNative.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ const int CONSUMED = -2;
1717
// (CONSUMED - thread pool is initialized)
1818
// or
1919
// NOT_SET -> CONSUMED
20-
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
2120
std::atomic<int> num_interop_threads{NOT_SET};
2221

2322
// thread pool global instance is hidden,
@@ -46,7 +45,6 @@ std::shared_ptr<TaskThreadPoolBase> create_c10_threadpool(
4645

4746
} // namespace
4847

49-
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
5048
C10_REGISTER_CREATOR(ThreadPoolRegistry, C10, create_c10_threadpool);
5149

5250
void set_num_interop_threads(int nthreads) {

Diff for: aten/src/ATen/SequenceNumber.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ namespace at {
44
namespace sequence_number {
55

66
namespace {
7-
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
87
thread_local uint64_t sequence_nr_ = 0;
98
} // namespace
109

Diff for: aten/src/ATen/VmapMode.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace at {
44
namespace impl {
55

6-
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
76
thread_local int64_t VmapMode_current_vmap_level = 0;
87

98
int64_t VmapMode::current_vmap_level() {

Diff for: aten/src/ATen/autocast_mode.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,12 @@ namespace {
4747
// directly against incoming TensorImpl*s.
4848
using weakref_type = c10::weak_intrusive_ptr<TensorImpl, UndefinedTensorImpl>;
4949
using val_type = std::tuple<weakref_type, Tensor>;
50-
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
5150
thread_local std::unordered_map<TensorImpl*, val_type> cached_casts;
5251

5352
// nesting tracks the nesting depth of the Python-side context manager.
5453
// When the autocast context manager exits to a nesting level that's outside
5554
// any instance of autocast (which should occur at the end of each forward pass)
5655
// it calls clear_cache() to ensure cached Tensors don't leak outside the autocasting region.
57-
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
5856
thread_local int nesting = 0;
5957

6058
// autocast_cpu_dtype is the lower_precision_fp used by AutocastCPU.

Diff for: aten/src/ATen/benchmarks/quantize_per_channel.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,7 @@ static void GenerateSizes2d(benchmark::internal::Benchmark* b) {
7979
}
8080
}
8181

82-
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
8382
BENCHMARK(quantize_per_channel_2d)->Apply(GenerateSizes2d);
84-
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
8583
BENCHMARK(quantize_per_channel_4d_contiguous)->Apply(GenerateSizes4d);
86-
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
8784
BENCHMARK(quantize_per_channel_4d_channels_last)->Apply(GenerateSizes4d);
8885
BENCHMARK_MAIN();

Diff for: aten/src/ATen/benchmarks/stateful_conv1d.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,5 @@ static void GenerateSizes(benchmark::internal::Benchmark* b) {
8282
}
8383
}
8484

85-
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
8685
BENCHMARK(stateful_conv1d)->Apply(GenerateSizes);
8786
BENCHMARK_MAIN();

Diff for: aten/src/ATen/benchmarks/tensor_add.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,5 @@ static void GenerateSizes(benchmark::internal::Benchmark* b) {
2626
}
2727
}
2828

29-
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
3029
BENCHMARK(tensor_add)->Apply(GenerateSizes);
3130
BENCHMARK_MAIN();

Diff for: aten/src/ATen/core/Dimname.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace at {
66

7-
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
87
static Symbol kWildcard = Symbol::dimname("*");
98

109
std::ostream& operator<<(std::ostream& out, const Dimname& dimname) {

0 commit comments

Comments
 (0)