Skip to content

Commit 8629f9b

Browse files
cyyeverpytorchmergebot
authored andcommitted
Remove more unused variables in tests (pytorch#127510)
Follows pytorch#127379 Pull Request resolved: pytorch#127510 Approved by: https://github.com/Skylion007, https://github.com/r-barnes
1 parent 0aaac68 commit 8629f9b

File tree

6 files changed

+5
-12
lines changed

6 files changed

+5
-12
lines changed

test/cpp/api/CMakeLists.txt

-3
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@ endif()
5151
add_executable(test_api ${TORCH_API_TEST_SOURCES})
5252
target_include_directories(test_api PRIVATE ${ATen_CPU_INCLUDE})
5353
target_link_libraries(test_api PRIVATE torch gtest)
54-
if(NOT MSVC)
55-
target_compile_options_if_supported(test_api -Wno-unused-variable)
56-
endif()
5754

5855
if(USE_CUDA)
5956
target_compile_definitions(test_api PRIVATE "USE_CUDA")

test/cpp/api/serialize.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,6 @@ TEST(SerializeTest, Optim_RMSprop) {
806806
for (const auto i : c10::irange(params1_2_.size())) {
807807
if (i != (params1_2_.size() - 1)) {
808808
auto key_ = params_[i].unsafeGetTensorImpl();
809-
auto key1_2_ = params1_2_[i].unsafeGetTensorImpl();
810809
const RMSpropParamState& curr_state_ =
811810
static_cast<const RMSpropParamState&>(*(optim1_state.at(key_).get()));
812811
RMSpropParamState& curr_state1_2_ =

test/cpp/tensorexpr/test_llvm.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -1474,7 +1474,6 @@ TEST(LLVM, RFactorReduction) {
14741474
TEST(LLVM, RFactorVectorizedReduction) {
14751475
int M = 128;
14761476
int N = 64;
1477-
const int kTotalSize = M * N;
14781477

14791478
BufHandle a("a", {1, M, N}, kFloat);
14801479

test/cpp/tensorexpr/test_reductions.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -1092,6 +1092,7 @@ TEST(Reductions, ReduceOverSplitRfactor) {
10921092

10931093
// Check the IR to verify the rfactored reduce is eliminated.
10941094
// TODO: The alloc free should be eliminated here since it is size 0.
1095+
/*
10951096
const std::string& verification_pattern =
10961097
R"IR(
10971098
# CHECK: Allocate(tmp_buf); // dtype=float, dims=[0]
@@ -1102,6 +1103,7 @@ TEST(Reductions, ReduceOverSplitRfactor) {
11021103
# CHECK: }
11031104
# CHECK: }
11041105
# CHECK: Free(tmp_buf);)IR";
1106+
*/
11051107
// TODO: rfactor output is not consistent yet, will fix (@nickg).
11061108
// torch::jit::testing::FileCheck().run(verification_pattern, oss.str());
11071109
}

torch/csrc/api/include/torch/data/dataloader/stateful.h

+2-4
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,8 @@ class StatefulDataLoader : public DataLoaderBase<
3636

3737
/// Constructs the `StatefulDataLoader` from a `dataset` and some `options`.
3838
StatefulDataLoader(Dataset dataset, DataLoaderOptions options)
39-
: super(
40-
std::move(options),
41-
std::make_unique<Dataset>(std::move(dataset))) {
42-
for (const auto w : c10::irange(this->options_.workers)) {
39+
: super(options, std::make_unique<Dataset>(std::move(dataset))) {
40+
for ([[maybe_unused]] const auto _ : c10::irange(this->options_.workers)) {
4341
// As opposed to the stateless case, here all worker threads access the
4442
// same underlying dataset.
4543
this->workers_.emplace_back(

torch/csrc/jit/api/module.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -541,9 +541,7 @@ struct slot_list_impl {
541541
size_t size() const {
542542
if (!size_) {
543543
size_ = size_t(0);
544-
// NOLINTNEXTLINE(clang-diagnostic-unused-variable)
545-
for (const value_type& s : *(this)) {
546-
(void)s; // Suppress unused variable warning
544+
for ([[maybe_unused]] const value_type& _ : *(this)) {
547545
++*size_;
548546
}
549547
}

0 commit comments

Comments
 (0)