Fix a shadowed variable (#64695)
authorRichard Barnes <rbarnes@fb.com>
Thu, 9 Sep 2021 17:30:59 +0000 (10:30 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Thu, 9 Sep 2021 17:34:01 +0000 (10:34 -0700)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/64695

Resolves this warning:
```
caffe2/aten/src/ATen/ParallelOpenMP.h:109:63: warning: declaration of 'int64_t begin' shadows a parameter [-Wshadow=compatible-local]
  109 |   internal::invoke_parallel(begin, end, grain_size, [&](int64_t begin, int64_t end) {
      |                                                       ~~~~~~~~^~~~~
caffe2/aten/src/ATen/ParallelOpenMP.h:86:1: note: shadowed declaration is here
   85 | inline scalar_t parallel_reduce(
      |                 ~~~~~~~~~~~~~~~~
   86 |     const int64_t begin,
      | ^   ~
```

Test Plan: Sandcastle

Reviewed By: ngimel

Differential Revision: D30816128

fbshipit-source-id: 3adff6d94eea9fbd65885e88283cae10b87dba18

aten/src/ATen/ParallelOpenMP.h

index ce3a8b3..d911c8a 100644 (file)
@@ -106,10 +106,12 @@ inline scalar_t parallel_reduce(
   }
 
   c10::SmallVector<scalar_t, 64> results(at::get_num_threads(), ident);
-  internal::invoke_parallel(begin, end, grain_size, [&](int64_t begin, int64_t end) {
-    auto tid = at::get_thread_num();
-    results[tid] = f(begin, end, ident);
-  });
+  internal::invoke_parallel(begin, end, grain_size,
+    [&](const int64_t my_begin, const int64_t my_end) {
+      const auto tid = at::get_thread_num();
+      results[tid] = f(my_begin, my_end, ident);
+    }
+  );
 
   scalar_t result = ident;
   for (auto partial_result : results) {