diff --git a/CMakeLists.txt b/CMakeLists.txt index 05259984f3340a..04b32ba7c24fd1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -744,7 +744,6 @@ if(NOT MSVC) string(APPEND CMAKE_CXX_FLAGS " -Wno-unknown-pragmas") string(APPEND CMAKE_CXX_FLAGS " -Wno-sign-compare") string(APPEND CMAKE_CXX_FLAGS " -Wno-unused-parameter") - string(APPEND CMAKE_CXX_FLAGS " -Wno-unused-variable") string(APPEND CMAKE_CXX_FLAGS " -Wno-unused-function") string(APPEND CMAKE_CXX_FLAGS " -Wno-unused-result") string(APPEND CMAKE_CXX_FLAGS " -Wno-unused-local-typedefs") @@ -1068,6 +1067,9 @@ endif() # ---[ JNI if(BUILD_JNI) + if(NOT MSVC) + string(APPEND CMAKE_CXX_FLAGS " -Wno-unused-variable") + endif() set(BUILD_LIBTORCH_WITH_JNI 1) set(FBJNI_SKIP_TESTS 1) add_subdirectory(android/pytorch_android) diff --git a/aten/src/ATen/mkl/Limits.h b/aten/src/ATen/mkl/Limits.h index b0d3829e458ed1..2a0ed662a6d5cd 100644 --- a/aten/src/ATen/mkl/Limits.h +++ b/aten/src/ATen/mkl/Limits.h @@ -6,6 +6,6 @@ namespace at { namespace native { // Since size of MKL_LONG varies on different platforms (linux 64 bit, windows // 32 bit), we need to programmatically calculate the max. - static int64_t MKL_LONG_MAX = ((1LL << (sizeof(MKL_LONG) * 8 - 2)) - 1) * 2 + 1; + constexpr int64_t MKL_LONG_MAX = ((1LL << (sizeof(MKL_LONG) * 8 - 2)) - 1) * 2 + 1; }} // namespace diff --git a/aten/src/ATen/test/cuda_stream_test.cpp b/aten/src/ATen/test/cuda_stream_test.cpp index 6bf83d2fcdffa6..5a117e772731cc 100644 --- a/aten/src/ATen/test/cuda_stream_test.cpp +++ b/aten/src/ATen/test/cuda_stream_test.cpp @@ -173,6 +173,7 @@ TEST(TestStream, StreamPoolTest) { if (!at::cuda::is_available()) return; std::vector streams{}; for (const auto i : c10::irange(200)) { + (void)i; streams.emplace_back(at::cuda::getStreamFromPool()); } diff --git a/aten/src/ATen/test/cuda_tensor_interop_test.cpp b/aten/src/ATen/test/cuda_tensor_interop_test.cpp index 89019d7950b9a4..2a2833b7b2748a 100644 --- a/aten/src/ATen/test/cuda_tensor_interop_test.cpp +++ b/aten/src/ATen/test/cuda_tensor_interop_test.cpp @@ -84,6 +84,8 @@ TEST(CUDAPytorchToCaffe2, Op) { auto* c2_tensor_a = BlobSetTensor(workspace.CreateBlob("a"), caffe2::Tensor(at_tensor_a)); auto* c2_tensor_b = BlobSetTensor(workspace.CreateBlob("b"), caffe2::Tensor(at_tensor_b)); + (void)c2_tensor_a; + (void)c2_tensor_b; // Test Alias { diff --git a/aten/src/ATen/test/math_kernel_test.cpp b/aten/src/ATen/test/math_kernel_test.cpp index 10bdd73b2d02f2..b6d7b5ae355a7b 100644 --- a/aten/src/ATen/test/math_kernel_test.cpp +++ b/aten/src/ATen/test/math_kernel_test.cpp @@ -54,8 +54,6 @@ TEST(MathKernelTest, NativeGroupNorm) { TEST(MathKernelTest, NativeLayerNorm) { const auto input = rand({20, 10, 10, 10}); const auto input_shape = input.sizes(); - // NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores) - const auto input_ndim = input.dim(); double eps = 1e-05; for (bool undef_weight: {true, false}) { diff --git a/benchmarks/cpp/nvfuser/CMakeLists.txt b/benchmarks/cpp/nvfuser/CMakeLists.txt index 1024c4012a3cea..22b23e5e9ab7da 100644 --- a/benchmarks/cpp/nvfuser/CMakeLists.txt +++ b/benchmarks/cpp/nvfuser/CMakeLists.txt @@ -15,4 +15,8 @@ if(USE_CUDA) main.cpp) target_link_libraries(nvfuser_bench PRIVATE torch_library benchmark) + if(NOT MSVC) + target_compile_options(nvfuser_bench PRIVATE -Wno-unused-variable) + endif() + endif() diff --git a/c10/test/CMakeLists.txt b/c10/test/CMakeLists.txt index acd9b4ded43846..a68d2b899bd79a 100644 --- a/c10/test/CMakeLists.txt +++ b/c10/test/CMakeLists.txt @@ -6,6 +6,9 @@ if(BUILD_TEST) get_filename_component(test_file_name ${test_src} NAME_WE) set(test_name "c10_${test_file_name}") add_executable(${test_name} "${test_src}") + if(NOT MSVC) + target_compile_options(${test_name} PRIVATE -Wno-unused-variable) + endif() target_link_libraries(${test_name} c10 gmock gtest gtest_main) add_test(NAME ${test_name} COMMAND $) if(INSTALL_TEST) diff --git a/caffe2/CMakeLists.txt b/caffe2/CMakeLists.txt index 5f2892350fe901..3743b5703b6209 100644 --- a/caffe2/CMakeLists.txt +++ b/caffe2/CMakeLists.txt @@ -1762,6 +1762,9 @@ if(BUILD_TEST) target_include_directories(${test_name} PRIVATE $) target_include_directories(${test_name} PRIVATE $) target_include_directories(${test_name} PRIVATE ${Caffe2_CPU_INCLUDE}) + if(NOT MSVC) + target_compile_options(${test_name} PRIVATE -Wno-unused-variable) + endif() add_test(NAME ${test_name} COMMAND $) if(INSTALL_TEST) install(TARGETS ${test_name} DESTINATION test) diff --git a/caffe2/core/blob_serialization.cc b/caffe2/core/blob_serialization.cc index 70d1b59dc814ff..1b2c58bacd467f 100644 --- a/caffe2/core/blob_serialization.cc +++ b/caffe2/core/blob_serialization.cc @@ -399,8 +399,8 @@ void TensorSerializer::SerializeWithOptions( std::vector> futures; if (tensor.numel() > chunk_size) { futures.reserve(FLAGS_caffe2_max_tensor_serializer_threads); - // NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores,clang-diagnostic-unused-variable) for (const auto i : c10::irange(FLAGS_caffe2_max_tensor_serializer_threads)) { + (void)i; futures.emplace_back(std::async(std::launch::async, task)); } } diff --git a/caffe2/operators/cast_op.h b/caffe2/operators/cast_op.h index ab0323fc52d41e..478f2f30380c28 100644 --- a/caffe2/operators/cast_op.h +++ b/caffe2/operators/cast_op.h @@ -19,7 +19,6 @@ class CastOp : public Operator { : Operator(operator_def, ws) { const ArgumentHelper helper(operator_def); TensorProto_DataType to = cast::GetCastDataType(helper, "to"); - TensorProto_DataType from = cast::GetCastDataType(helper, "from_type"); SetBody(to); } diff --git a/caffe2/operators/conv_op_cudnn.cc b/caffe2/operators/conv_op_cudnn.cc index cfbebcfe601c4a..36a5f4c4bcaeb2 100644 --- a/caffe2/operators/conv_op_cudnn.cc +++ b/caffe2/operators/conv_op_cudnn.cc @@ -576,7 +576,9 @@ bool CudnnConvOp::DoRunWithType() { return true; } +#if !CUDNN_VERSION_MIN(7, 0, 0) int group_offset_filter = filter.numel() / group_; +#endif // Set up the cudnn algorithms & workspace if necessary bool input_changed = (X.sizes() != cudnn_input_dims_); @@ -951,7 +953,9 @@ bool CudnnConvGradientOp::DoRunWithType() { "If you set group, the number of output channels should be divisible " "by group."); +#if !CUDNN_VERSION_MIN(7, 0, 0) int group_offset_filter = filter.numel() / group_; +#endif if (kernel_.size() == 1) { ConvPoolOpBase::ComputePads({H}); } else if (kernel_.size() == 2) { diff --git a/caffe2/operators/fused_rowwise_nbitfake_conversion_ops.cc b/caffe2/operators/fused_rowwise_nbitfake_conversion_ops.cc index 6a483a8fb011e6..914b8d8abc8a7e 100644 --- a/caffe2/operators/fused_rowwise_nbitfake_conversion_ops.cc +++ b/caffe2/operators/fused_rowwise_nbitfake_conversion_ops.cc @@ -25,11 +25,10 @@ float compress_uniform_simplified_( float inverse_scale = 1.0f / scale; float norm = 0.0f; - // NOLINTNEXTLINE(clang-diagnostic-unused-variable) - constexpr int VLEN = 8; int i = 0; #ifdef __AVX__ + constexpr int VLEN = 8; // vectorized loop __m256 norm_v = _mm256_setzero_ps(); for (; i < N / VLEN * VLEN; i += VLEN) { diff --git a/caffe2/operators/fused_rowwise_nbitfake_conversion_ops.h b/caffe2/operators/fused_rowwise_nbitfake_conversion_ops.h index 53462073e9b247..105f9902b21599 100644 --- a/caffe2/operators/fused_rowwise_nbitfake_conversion_ops.h +++ b/caffe2/operators/fused_rowwise_nbitfake_conversion_ops.h @@ -72,7 +72,6 @@ class FloatToFusedNBitFakeRowwiseQuantizedOp final CAFFE_THROW("Unsupported data type"); } - bool use_openmp = GREEDY; #ifdef _OPENMP vector tmp_vec(input_columns * (GREEDY ? omp_get_max_threads() : 1)); #else diff --git a/caffe2/operators/gather_fused_8bit_rowwise_op.h b/caffe2/operators/gather_fused_8bit_rowwise_op.h index b0d57436e09180..a111ff3eca4dbb 100644 --- a/caffe2/operators/gather_fused_8bit_rowwise_op.h +++ b/caffe2/operators/gather_fused_8bit_rowwise_op.h @@ -30,7 +30,6 @@ class GatherFused8BitRowwiseOp : public Operator { const std::vector shape = {indices.size(0), data.size(1) - 8}; auto* output = Output(0, shape, at::dtype()); - int block_size = shape[1]; auto block_bytesize = data.size_from_dim(1) * data.dtype().itemsize(); int N = indices.numel(); diff --git a/caffe2/operators/generate_proposals_op_util_nms.h b/caffe2/operators/generate_proposals_op_util_nms.h index 26e86c4407542f..ff68d49251c1e3 100644 --- a/caffe2/operators/generate_proposals_op_util_nms.h +++ b/caffe2/operators/generate_proposals_op_util_nms.h @@ -133,8 +133,7 @@ std::vector soft_nms_cpu_upright( // Find proposal with max score among remaining proposals int max_pos; - // NOLINTNEXTLINE(clang-diagnostic-unused-variable) - auto max_score = GetSubArray(*out_scores, pending).maxCoeff(&max_pos); + GetSubArray(*out_scores, pending).maxCoeff(&max_pos); int i = pending[max_pos]; keep.push_back(i); @@ -635,8 +634,7 @@ std::vector soft_nms_cpu_rotated( // Find proposal with max score among remaining proposals int max_pos; - // NOLINTNEXTLINE(clang-diagnostic-unused-variable) - auto max_score = GetSubArray(*out_scores, pending).maxCoeff(&max_pos); + GetSubArray(*out_scores, pending).maxCoeff(&max_pos); int i = pending[max_pos]; keep.push_back(i); diff --git a/caffe2/operators/h_softmax_op.cc b/caffe2/operators/h_softmax_op.cc index 333fab96afef38..9913e81c297279 100644 --- a/caffe2/operators/h_softmax_op.cc +++ b/caffe2/operators/h_softmax_op.cc @@ -458,8 +458,6 @@ bool HuffmanTreeHierarchyOp::RunOnDevice() { std::vector labelIndices; labelIndices.resize(num_classes_); - // NOLINTNEXTLINE(clang-diagnostic-unused-variable) - int current_node_index = 0; for (int i = 0; i < num_classes_; ++i) { Node node(i, labelCounts[i]); nodes.push(node); diff --git a/caffe2/operators/layer_norm_op.h b/caffe2/operators/layer_norm_op.h index e61eecdbd8c222..70a96d77ff21a2 100644 --- a/caffe2/operators/layer_norm_op.h +++ b/caffe2/operators/layer_norm_op.h @@ -132,8 +132,6 @@ class LayerNormGradientOp final : public Operator { template bool DoRunWithType() { const auto& dY = Input(0); - // NOLINTNEXTLINE(clang-diagnostic-unused-variable) - const auto& Y = Input(1); const auto& mean = Input(2); const auto& sigma = Input(3); const auto& X = Input(4); diff --git a/caffe2/operators/lengths_reducer_rowwise_8bit_ops.h b/caffe2/operators/lengths_reducer_rowwise_8bit_ops.h index e4c0366833e755..67d792f4ca23ce 100644 --- a/caffe2/operators/lengths_reducer_rowwise_8bit_ops.h +++ b/caffe2/operators/lengths_reducer_rowwise_8bit_ops.h @@ -53,7 +53,6 @@ class SparseLengths8BitsRowwiseOp : public Operator { "the second dim of scale_bias has to be equal to 2"); CAFFE_ENFORCE_EQ(1, indicesInput.dim(), "INDICES must be a vector"); const IndexType* indices = indicesInput.template data(); - int64_t dataToReduceSize = indicesInput.size(0); const int* lengths = lengthsInput.template data(); vector shape = dataInput.sizes().vec(); diff --git a/caffe2/operators/local_response_normalization_op_cudnn.cc b/caffe2/operators/local_response_normalization_op_cudnn.cc index 5795ac6716c13c..dc6a29965df31b 100644 --- a/caffe2/operators/local_response_normalization_op_cudnn.cc +++ b/caffe2/operators/local_response_normalization_op_cudnn.cc @@ -193,8 +193,6 @@ bool CuDNNLRNGradientOp::DoRunWithType() { bool CuDNNLRNGradientOp::RunOnDevice() { // dispatch based on contents of tensor(s) - const auto& X = Input(0); - const auto& Y = Input(1); const auto& dY = Input(2); auto* dX = Output(0); diff --git a/caffe2/operators/quantized/int8_add_op.h b/caffe2/operators/quantized/int8_add_op.h index ea5cb8d5114cdc..67b48f0a87d834 100644 --- a/caffe2/operators/quantized/int8_add_op.h +++ b/caffe2/operators/quantized/int8_add_op.h @@ -55,8 +55,10 @@ class Int8AddOp final : public Operator { initQNNPACK(); +#if !defined(FBCODE_CAFFE2) && defined(USE_INTERNAL_PTHREADPOOL_IMPL) pthreadpool_t threadpool = reinterpret_cast(ws_->GetThreadPool()); +#endif if (this->qnnpackOperator_ == nullptr) { const qnnp_status createStatus = qnnp_create_add_nc_q8( diff --git a/caffe2/operators/quantized/int8_channel_shuffle_op.h b/caffe2/operators/quantized/int8_channel_shuffle_op.h index 77a34c41c6be1d..52dabb31ed065a 100644 --- a/caffe2/operators/quantized/int8_channel_shuffle_op.h +++ b/caffe2/operators/quantized/int8_channel_shuffle_op.h @@ -47,7 +47,6 @@ class Int8ChannelShuffleOp final : public ConvPoolOpBase { const auto C = X.t.dim32(3); const auto G = this->group_; CAFFE_ENFORCE(C % G == 0, ""); - const auto B = X.t.numel() / C; initQNNPACK(); diff --git a/caffe2/operators/quantized/int8_conv_op.h b/caffe2/operators/quantized/int8_conv_op.h index a309be9c11a6cf..055e85141e2619 100644 --- a/caffe2/operators/quantized/int8_conv_op.h +++ b/caffe2/operators/quantized/int8_conv_op.h @@ -60,8 +60,10 @@ class Int8ConvOp final : public ConvPoolOpBase { runWithSharedBuffer(ws_, [&](Tensor* buffer) { initQNNPACK(); +#if !defined(FBCODE_CAFFE2) && defined(USE_INTERNAL_PTHREADPOOL_IMPL) pthreadpool_t threadpool = reinterpret_cast(ws_->GetThreadPool()); +#endif if (this->qnnpackObject_ == nullptr) { CAFFE_ENFORCE( diff --git a/caffe2/operators/quantized/int8_conv_transpose_op.h b/caffe2/operators/quantized/int8_conv_transpose_op.h index 66f9ff9471064e..797acc2748aef3 100644 --- a/caffe2/operators/quantized/int8_conv_transpose_op.h +++ b/caffe2/operators/quantized/int8_conv_transpose_op.h @@ -39,17 +39,12 @@ class Int8ConvTransposeOp final : public ConvTransposeUnpoolBase { const auto& W = Inputs()[1]->template Get(); const auto& B = Inputs()[2]->template Get(); auto* Y = Outputs()[0]->template GetMutable(); - const auto X_offset = -X.zero_point; - const auto W_offset = -W.zero_point; const int32_t Y_offset = this->template GetSingleArgument("Y_zero_point", 0); double Y_scale = this->template GetSingleArgument("Y_scale", 1); Y->scale = Y_scale; Y->zero_point = Y_offset; - const auto N = X.t.size(0); - const auto IH = X.t.size(1); - const auto IW = X.t.size(2); const auto IC = X.t.size(3); CHECK_EQ(IC, W.t.size(0)); @@ -64,8 +59,10 @@ class Int8ConvTransposeOp final : public ConvTransposeUnpoolBase { runWithSharedBuffer(ws_, [&](Tensor* buffer) { initQNNPACK(); +#if !defined(FBCODE_CAFFE2) && defined(USE_INTERNAL_PTHREADPOOL_IMPL) pthreadpool_t threadpool = reinterpret_cast(ws_->GetThreadPool()); +#endif if (this->qnnpackObject_ == nullptr) { const qnnp_status createStatus = qnnp_create_deconvolution2d_nhwc_q8( diff --git a/caffe2/operators/quantized/int8_fc_op.h b/caffe2/operators/quantized/int8_fc_op.h index 58e85caebebd52..3f0e65adc9f52a 100644 --- a/caffe2/operators/quantized/int8_fc_op.h +++ b/caffe2/operators/quantized/int8_fc_op.h @@ -47,8 +47,10 @@ class Int8FCOp final : public Operator { runWithSharedBuffer(ws_, [&](Tensor* buffer) { initQNNPACK(); +#if !defined(FBCODE_CAFFE2) && defined(USE_INTERNAL_PTHREADPOOL_IMPL) pthreadpool_t threadpool = reinterpret_cast(ws_->GetThreadPool()); +#endif if (this->qnnpackObject_ == nullptr) { const qnnp_status createStatus = qnnp_create_fully_connected_nc_q8( diff --git a/caffe2/operators/quantized/int8_quantize_op.h b/caffe2/operators/quantized/int8_quantize_op.h index 32bdd15ea1c334..7845107cf3e91c 100644 --- a/caffe2/operators/quantized/int8_quantize_op.h +++ b/caffe2/operators/quantized/int8_quantize_op.h @@ -19,10 +19,10 @@ void Int8Quantize( const int64_t N, const float Y_scale, const int32_t Y_offset) { - const float inv_scale = 1.0f / Y_scale; uint32_t i = 0; #ifdef INT8_NEON_SIMD + const float inv_scale = 1.0f / Y_scale; const float32x4_t vinv_scale = vdupq_n_f32(inv_scale); // magic float and magic int to take care of rounding // int magic_round(float f): interpret_int32(f + 12582912.0f) - 0x4B400000 diff --git a/caffe2/operators/quantized/int8_softmax_op.h b/caffe2/operators/quantized/int8_softmax_op.h index e62b2237b1cd2c..deba3a42c7d960 100644 --- a/caffe2/operators/quantized/int8_softmax_op.h +++ b/caffe2/operators/quantized/int8_softmax_op.h @@ -38,7 +38,6 @@ class Int8SoftmaxOp final : public Operator { * in-place, we may overwrite these parameters later, when we set * quantization parameters for output tensor. */ - const uint8_t X_zero_point = X.zero_point; const float X_scale = X.scale; Y->scale = Y_scale; diff --git a/caffe2/operators/text_file_reader.cc b/caffe2/operators/text_file_reader.cc index fe2680bc2a28e0..96250cdd25812f 100644 --- a/caffe2/operators/text_file_reader.cc +++ b/caffe2/operators/text_file_reader.cc @@ -141,8 +141,6 @@ class TextFileReaderReadOp : public Operator { (field > 0 && token.startDelimId == 1), "Invalid number of columns at row ", instance->rowsRead + rowsRead + 1); - // NOLINTNEXTLINE(clang-diagnostic-unused-variable) - const auto& meta = instance->fieldMetas[field]; char*& data = datas[field]; convert( (TensorProto_DataType)instance->fieldTypes[field], diff --git a/caffe2/operators/utility_ops.h b/caffe2/operators/utility_ops.h index f0810813333865..e76649346dc31d 100644 --- a/caffe2/operators/utility_ops.h +++ b/caffe2/operators/utility_ops.h @@ -686,8 +686,7 @@ class ScatterAssignOp : public Operator { const auto dataType = TypeMetaToDataType(data.dtype()); const auto slicesType = TypeMetaToDataType(slices.dtype()); const auto indicesType = TypeMetaToDataType(indices.dtype()); - // NOLINTNEXTLINE(clang-diagnostic-unused-variable) - auto* output = Output(0); + C10_UNUSED auto* output = Output(0); auto runner = GetRunner(dataType, slicesType, indicesType); (this->*runner)(); diff --git a/caffe2/operators/weighted_sample_op.cc b/caffe2/operators/weighted_sample_op.cc index 8243fa1ce7ed95..cfc625f9f7c3aa 100644 --- a/caffe2/operators/weighted_sample_op.cc +++ b/caffe2/operators/weighted_sample_op.cc @@ -57,8 +57,7 @@ bool WeightedSampleOp::RunOnDevice() { } } } else { - // NOLINTNEXTLINE(clang-diagnostic-unused-variable,clang-analyzer-deadcode.DeadStores) - auto* out_idx = Output(0, {0}, at::dtype()); + C10_UNUSED auto* out_idx = Output(0, {0}, at::dtype()); if (OutputSize() == 2) { auto* out_value = Output(1, {0}, at::dtype()); out_value->template mutable_data(); diff --git a/caffe2/opt/bound_shape_inferencer.cc b/caffe2/opt/bound_shape_inferencer.cc index 344242273db363..e359d17c57c1ce 100644 --- a/caffe2/opt/bound_shape_inferencer.cc +++ b/caffe2/opt/bound_shape_inferencer.cc @@ -436,13 +436,6 @@ void BoundShapeInferencer::InferSparseLengthsSum(const OperatorDef& op) { op.type() == "SparseLengthsWeightedSum4BitRowwiseSparse" || op.type() == "SparseLengthsSum4BitRowwiseSparse"); - // NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores,clang-diagnostic-unused-variable) - const bool isSparse = - (op.type() == "SparseLengthsSum4BitRowwiseSparse" || - op.type() == "SparseLengthsWeightedSum4BitRowwiseSparse" || - op.type() == "SparseLengthsSum8BitRowwiseSparse" || - op.type() == "SparseLengthsWeightedSum8BitRowwiseSparse"); - if (weight) { CAFFE_ENFORCE_GE( op.input_size(), diff --git a/caffe2/opt/optimize_ideep.cc b/caffe2/opt/optimize_ideep.cc index e12d128b26d375..687126ee327d5d 100644 --- a/caffe2/opt/optimize_ideep.cc +++ b/caffe2/opt/optimize_ideep.cc @@ -533,8 +533,6 @@ bool fuseActivation(repr::NNModule* nn, caffe2::Workspace* ws) { continue; } auto relu_node = consumers.front(); - // NOLINTNEXTLINE(clang-diagnostic-unused-variable,clang-analyzer-deadcode.DeadStores) - auto relu = repr::nn::get(relu_node); auto relu_outputs = repr::nn::getOutputs(relu_node); if (relu_outputs.size() != 1) { @@ -893,10 +891,6 @@ void preConvertFiltersFormat(repr::NNModule* nn, caffe2::Workspace* ws) { initValue(strides, {1, 1}); auto pads = convTranspose->getPads(); initValue(pads, {0, 0, 0, 0}); - // NOLINTNEXTLINE(clang-diagnostic-unused-variable,clang-analyzer-deadcode.DeadStores) - auto* op = getMutableOpDef(*convTranspose); - // NOLINTNEXTLINE(clang-diagnostic-unused-variable) - auto aalgorithm = ialgo::deconvolution_direct; auto dataType = filter->get_data_type(); ideep::tensor::dims filter_dims_mkldnn{filter->get_dim(1), filter->get_dim(0), diff --git a/caffe2/quantization/server/dynamic_histogram.cc b/caffe2/quantization/server/dynamic_histogram.cc index 25648cbb7fcf7b..c7c7286bd6a1fc 100644 --- a/caffe2/quantization/server/dynamic_histogram.cc +++ b/caffe2/quantization/server/dynamic_histogram.cc @@ -64,12 +64,12 @@ void RemapHistograms(Histogram& src_hist, Histogram& dst_hist) { // NOLINTNEXTLINE(bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions) float dst_bin_begin = dst_hist.Min() + dst_bin_width * dst_bin; float dst_bin_end = dst_bin_begin + dst_bin_width; - // NOLINTNEXTLINE(clang-diagnostic-unused-variable,clang-analyzer-deadcode.DeadStores) int dst_bin2 = // NOLINTNEXTLINE(bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions) dst_bin_width == 0 ? 0 : (src_bin_end - dst_hist.Min()) / dst_bin_width; // 1 src_bin is mapped to at most 2 dst bin assert(dst_bin2 <= dst_bin + 2); + (void)dst_bin2; // dst_bin_cnt is the count from src_bin that should go to dst_bin // The remainder should go to dst_bin2 diff --git a/caffe2/quantization/server/fbgemm_pack_op.cc b/caffe2/quantization/server/fbgemm_pack_op.cc index 22fa8a6fc790dc..99256fc630d318 100644 --- a/caffe2/quantization/server/fbgemm_pack_op.cc +++ b/caffe2/quantization/server/fbgemm_pack_op.cc @@ -698,9 +698,8 @@ TypeIdentifier Int8ConvDNNLowpPackedWeightBlobShapeFunctions::GetTypeMetaId() { TypeMeta Int8FCDNNLowpPackedWeightBlobShapeFunctions::GetExternalTensorType( const void* c) { - // NOLINTNEXTLINE(clang-diagnostic-unused-variable) - const Int8FCDNNLowPPackedWeightBlob* int8_tensor = - reinterpret_cast(c); + // const Int8FCDNNLowPPackedWeightBlob* int8_tensor = + // reinterpret_cast(c); // We forced the output type to be uint8_t since we know it always is. // If it is going to be implemented elsewhere, we might need to change here. // return (int8_tensor->original_tensor).dtype(); @@ -709,9 +708,8 @@ TypeMeta Int8FCDNNLowpPackedWeightBlobShapeFunctions::GetExternalTensorType( TypeMeta Int8ConvDNNLowpPackedWeightBlobShapeFunctions::GetExternalTensorType( const void* c) { - // NOLINTNEXTLINE(clang-diagnostic-unused-variable) - const Int8ConvDNNLowPPackedWeightBlob* int8_tensor = - reinterpret_cast(c); + // const Int8ConvDNNLowPPackedWeightBlob* int8_tensor = + // reinterpret_cast(c); // return (int8_tensor->original_tensor).dtype(); return TypeMeta::Make(); } diff --git a/caffe2/quantization/server/p99.cc b/caffe2/quantization/server/p99.cc index 85f4c3567b15a9..22a7e2230b90c9 100644 --- a/caffe2/quantization/server/p99.cc +++ b/caffe2/quantization/server/p99.cc @@ -21,11 +21,7 @@ TensorQuantizationParams P99::ChooseQuantizationParams( float org_min = min; // NOLINTNEXTLINE(cppcoreguidelines-narrowing-conversions,bugprone-narrowing-conversions) float bin_width = (max - min) / nbins; - // NOLINTNEXTLINE(clang-diagnostic-unused-variable,bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions,clang-analyzer-deadcode.DeadStores) - int zero_bin = round(-min / bin_width); - // NOLINTNEXTLINE(clang-diagnostic-unused-variable) - int best_width = 0; double total_sum = 0; for (int i = 0; i < nbins; ++i) { total_sum += bins_f[i]; diff --git a/caffe2/share/contrib/nnpack/conv_op.cc b/caffe2/share/contrib/nnpack/conv_op.cc index bfc5ec16544150..7e429774c4c893 100644 --- a/caffe2/share/contrib/nnpack/conv_op.cc +++ b/caffe2/share/contrib/nnpack/conv_op.cc @@ -152,8 +152,7 @@ bool NNPACKConvOp::RunOnDeviceWithOrderNCHW() { auto& filter = Input(1); auto* Y = Output(0); CAFFE_ENFORCE(X.ndim() == 4, "Input dim should be 4"); - // NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores,clang-diagnostic-unused-variable) - const int N = X.dim32(0), C = X.dim32(1), H = X.dim32(2), W = X.dim32(3); + const int C = X.dim32(1), H = X.dim32(2), W = X.dim32(3); CAFFE_ENFORCE(filter.ndim() == 4, ""); const int M = filter.dim32(0); CAFFE_ENFORCE(C % this->group_ == 0, ""); @@ -181,12 +180,6 @@ bool NNPACKConvOp::RunOnDeviceWithOrderNCHW() { biasData = dummyBias_.data(); } - // NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores,clang-diagnostic-unused-variable) - const size_t batch_size = X.dim32(0); - // NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores,clang-diagnostic-unused-variable) - const size_t input_channels = X.dim32(1); - // NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores,clang-diagnostic-unused-variable) - const size_t output_channels = Y->dim32(1); const nnp_size input_size = {.width = static_cast(X.dim32(3)), .height = static_cast(X.dim32(2))}; // filter is MCHW diff --git a/test/benchmark_utils/test_benchmark_utils.py b/test/benchmark_utils/test_benchmark_utils.py index 835fc89d033c17..58d8543db12f20 100644 --- a/test/benchmark_utils/test_benchmark_utils.py +++ b/test/benchmark_utils/test_benchmark_utils.py @@ -170,7 +170,7 @@ def test_timer(self): @unittest.skipIf(IS_SANDCASTLE, "C++ timing is OSS only.") def test_timer_tiny_fast_snippet(self): timer = benchmark_utils.Timer( - 'auto x = 1;', + 'auto x = 1;(void)x;', timer=timeit.default_timer, language=benchmark_utils.Language.CPP, ) diff --git a/test/cpp/api/CMakeLists.txt b/test/cpp/api/CMakeLists.txt index f1fb4b6123a0f1..373895a0ce44d3 100644 --- a/test/cpp/api/CMakeLists.txt +++ b/test/cpp/api/CMakeLists.txt @@ -53,6 +53,9 @@ endif() add_executable(test_api ${TORCH_API_TEST_SOURCES}) target_include_directories(test_api PRIVATE ${ATen_CPU_INCLUDE}) target_link_libraries(test_api PRIVATE torch gtest) +if(NOT MSVC) + target_compile_options(test_api PRIVATE -Wno-unused-variable) +endif() if(USE_CUDA) target_link_libraries(test_api PRIVATE diff --git a/test/cpp/jit/CMakeLists.txt b/test/cpp/jit/CMakeLists.txt index d398e783194f6a..81ddaad8d1b108 100644 --- a/test/cpp/jit/CMakeLists.txt +++ b/test/cpp/jit/CMakeLists.txt @@ -97,6 +97,9 @@ endif(MSVC) target_link_libraries(test_jit PRIVATE ${JIT_TEST_DEPENDENCIES}) target_include_directories(test_jit PRIVATE ${ATen_CPU_INCLUDE}) +if(NOT MSVC) + target_compile_options(test_jit PRIVATE -Wno-unused-variable) +endif() if(LINUX) #Update to target_link_options when CMake version can be upgraded diff --git a/test/cpp/jit/test_backend_compiler_lib.cpp b/test/cpp/jit/test_backend_compiler_lib.cpp index 2aa6460cb8a33d..63aa4ecb6f7e0e 100644 --- a/test/cpp/jit/test_backend_compiler_lib.cpp +++ b/test/cpp/jit/test_backend_compiler_lib.cpp @@ -89,7 +89,6 @@ class BackendWithCompiler : public PyTorchBackendInterface { at::Tensor h = val1.toTensor(); c10::List output_list; - double scalar_val = 1.0; for (const auto& token : handle.toList()) { IValue val = token; auto instruction = val.toTuple()->elements()[0].toStringRef(); diff --git a/test/cpp/tensorexpr/CMakeLists.txt b/test/cpp/tensorexpr/CMakeLists.txt index 04dd9a133f3354..2a467e848d6a98 100644 --- a/test/cpp/tensorexpr/CMakeLists.txt +++ b/test/cpp/tensorexpr/CMakeLists.txt @@ -38,6 +38,9 @@ add_executable(test_tensorexpr target_link_libraries(test_tensorexpr PRIVATE torch gtest) target_include_directories(test_tensorexpr PRIVATE ${ATen_CPU_INCLUDE}) target_compile_definitions(test_tensorexpr PRIVATE USE_GTEST) +if(NOT MSVC) + target_compile_options(test_tensorexpr PRIVATE -Wno-unused-variable) +endif() add_executable(tutorial_tensorexpr ${TENSOREXPR_TEST_ROOT}/tutorial.cpp) target_link_libraries(tutorial_tensorexpr PRIVATE torch) diff --git a/torch/CMakeLists.txt b/torch/CMakeLists.txt index 38baee4799b548..4d53eb080a072a 100644 --- a/torch/CMakeLists.txt +++ b/torch/CMakeLists.txt @@ -361,6 +361,10 @@ if(USE_PRECOMPILED_HEADERS) "$<$:ATen/ATen.h>") endif() +if(NOT MSVC) + target_compile_options(torch_python PRIVATE -Wno-unused-variable) +endif() + # Required workaround for generated sources # See https://samthursfield.wordpress.com/2015/11/21/cmake-dependencies-between-targets-and-files-and-custom-commands/#custom-commands-in-different-directories add_dependencies(torch_python generate-torch-sources) diff --git a/torch/csrc/deploy/loader.cpp b/torch/csrc/deploy/loader.cpp index cbf093d2bb8a0b..a95cf6a272cc51 100644 --- a/torch/csrc/deploy/loader.cpp +++ b/torch/csrc/deploy/loader.cpp @@ -1046,7 +1046,6 @@ struct __attribute__((visibility("hidden"))) CustomLibraryImpl } at::optional tls_lookup_symbol(Elf64_Xword r_info) { - const uint32_t r_type = ELF64_R_TYPE(r_info); const uint32_t r_sym = ELF64_R_SYM(r_info); if (r_sym == 0) { diff --git a/torch/csrc/deploy/test_deploy.cpp b/torch/csrc/deploy/test_deploy.cpp index 1eb2e74d467526..e0ad7bc3d550ea 100644 --- a/torch/csrc/deploy/test_deploy.cpp +++ b/torch/csrc/deploy/test_deploy.cpp @@ -107,8 +107,8 @@ TEST(TorchpyTest, MultiSerialSimpleModel) { size_t ninterp = 3; std::vector outputs; - // NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores) for (const auto i : c10::irange(ninterp)) { + (void)i; outputs.push_back(model({input.alias()}).toTensor()); } @@ -151,11 +151,12 @@ TEST(TorchpyTest, ThreadedSimpleModel) { std::vector outputs; std::vector> futures; - // NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores) for (const auto i : c10::irange(nthreads)) { + (void)i; futures.push_back(std::async(std::launch::async, [&model]() { auto input = torch::ones({10, 20}); - for (const auto i : c10::irange(100)) { + for (const auto j : c10::irange(100)) { + (void)j; model({input.alias()}).toTensor(); } auto result = model({input.alias()}).toTensor(); @@ -230,8 +231,8 @@ TEST(TorchpyTest, TaggingRace) { constexpr int64_t trials = 4; constexpr int64_t nthreads = 16; torch::deploy::InterpreterManager m(nthreads); - // NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores) for (const auto n : c10::irange(trials)) { + (void)n; at::Tensor t = torch::empty(2); std::atomic success(0); std::atomic failed(0); @@ -283,6 +284,7 @@ TEST(TorchpyTest, FxModule) { std::vector outputs; auto input = torch::ones({5, 10}); for (const auto i : c10::irange(nthreads)) { + (void)i; outputs.push_back(model({input.alias()}).toTensor()); } diff --git a/torch/csrc/distributed/c10d/ProcessGroupMPI.cpp b/torch/csrc/distributed/c10d/ProcessGroupMPI.cpp index b75f4417e832aa..714f3a84deb61f 100644 --- a/torch/csrc/distributed/c10d/ProcessGroupMPI.cpp +++ b/torch/csrc/distributed/c10d/ProcessGroupMPI.cpp @@ -270,6 +270,7 @@ c10::intrusive_ptr ProcessGroupMPI::createProcessGroupMPI( bool groupComm_updated = false; MPI_Barrier(MPI_COMM_WORLD); for (const auto i : c10::irange(kMaxNumRetries)) { + (void)i; if (MPI_Comm_create(MPI_COMM_WORLD, ranksGroup, &groupComm)) { groupComm_updated = true; break; diff --git a/torch/csrc/distributed/c10d/ProcessGroupNCCL.cpp b/torch/csrc/distributed/c10d/ProcessGroupNCCL.cpp index 57eecc6bd81a15..2d31d25658dfef 100644 --- a/torch/csrc/distributed/c10d/ProcessGroupNCCL.cpp +++ b/torch/csrc/distributed/c10d/ProcessGroupNCCL.cpp @@ -939,6 +939,7 @@ std::vector>& ProcessGroupNCCL::getNCCLComm( // created before encountering any communication calls. This is why we need // the following for loop. for (const auto i : c10::irange(ncclActiveGroupCounter_)) { + (void)i; C10D_NCCL_CHECK(ncclGroupEnd(), c10::nullopt); } @@ -978,6 +979,7 @@ std::vector>& ProcessGroupNCCL::getNCCLComm( // See [Group Start/End Note] for (const auto i : c10::irange(ncclActiveGroupCounter_)) { + (void)i; C10D_NCCL_CHECK(ncclGroupStart(), c10::nullopt); } diff --git a/torch/csrc/distributed/c10d/reducer.cpp b/torch/csrc/distributed/c10d/reducer.cpp index 1d54f365620561..4615174c8d79e8 100644 --- a/torch/csrc/distributed/c10d/reducer.cpp +++ b/torch/csrc/distributed/c10d/reducer.cpp @@ -1383,8 +1383,6 @@ void Reducer::finalize_bucket_dense(Bucket& bucket) { auto& replica = bucket.replicas[replica_index]; for (const auto intra_bucket_index : c10::irange(replica.variables.size())) { auto& variable = replica.variables[intra_bucket_index]; - const auto offset = replica.offsets[intra_bucket_index]; - const auto length = replica.lengths[intra_bucket_index]; bool global_unused = false; // See Note [Skip allreducing local_used_map_dev] @@ -1634,6 +1632,7 @@ void Reducer::sync_bucket_indices( std::vector bucket; bucket.reserve(bucket_size); for (const auto j : c10::irange(bucket_size)) { + (void)j; bucket.push_back(indices_accessor[indices_accessor_Index++]); } bucket_indices.emplace_back(std::move(bucket)); diff --git a/torch/csrc/jit/codegen/cuda/lower_thread_predicate.cpp b/torch/csrc/jit/codegen/cuda/lower_thread_predicate.cpp index d8a6c7f79d9b0b..fe72baf085133f 100644 --- a/torch/csrc/jit/codegen/cuda/lower_thread_predicate.cpp +++ b/torch/csrc/jit/codegen/cuda/lower_thread_predicate.cpp @@ -280,7 +280,7 @@ void ThreadPredicateMap::insert( kir::Bool* ThreadPredicateMap::getPredicate(const TensorView* tv) const { // No thread predicate is needed when tv is an output of a // parallel broadcast expression. - if (auto bop = dynamic_cast(tv->definition())) { + if (dynamic_cast(tv->definition())) { if (getParallelBroadcastDomains(tv).any()) { return kir::IrBuilder(GpuLower::current()->kernel()).trueVal(); } diff --git a/torch/csrc/jit/frontend/ir_emitter.cpp b/torch/csrc/jit/frontend/ir_emitter.cpp index 4c066c27c3b3dc..52ad5fd47d5bcb 100644 --- a/torch/csrc/jit/frontend/ir_emitter.cpp +++ b/torch/csrc/jit/frontend/ir_emitter.cpp @@ -5163,7 +5163,7 @@ std::unique_ptr CompilationUnit::define( if (shouldMangle) { // If `shouldMangle` is set, we should generate a unique name for this // function if there is already an existing one. - if (auto fn = find_function(name)) { + if (find_function(name)) { name = mangle(name); } } diff --git a/torch/csrc/jit/frontend/sugared_value.cpp b/torch/csrc/jit/frontend/sugared_value.cpp index a5f000769badc5..dbb4b55e33bb6e 100644 --- a/torch/csrc/jit/frontend/sugared_value.cpp +++ b/torch/csrc/jit/frontend/sugared_value.cpp @@ -153,7 +153,7 @@ std::shared_ptr SimpleValue::attr( } } else if (auto classType = value_->type()->cast()) { // This is a class, emit the proper attribute lookup - if (auto method = classType->findMethod(field)) { + if (classType->findMethod(field)) { return std::make_shared(getValue(), field); } if (classType->hasAttribute(field)) { @@ -169,7 +169,7 @@ std::shared_ptr SimpleValue::attr( } } else if (auto iface = value_->type()->cast()) { // accessing methods of interfaces - if (auto schema = iface->getMethod(field)) { + if (iface->getMethod(field)) { return std::make_shared(getValue(), field); } } else if (auto enum_type = value_->type()->cast()) { diff --git a/torch/csrc/jit/mobile/promoted_prim_ops.cpp b/torch/csrc/jit/mobile/promoted_prim_ops.cpp index c96f09045c2d1c..5506e4debb3880 100644 --- a/torch/csrc/jit/mobile/promoted_prim_ops.cpp +++ b/torch/csrc/jit/mobile/promoted_prim_ops.cpp @@ -166,7 +166,7 @@ void numToTensorBool(Stack& stack) { push(stack, at::scalar_to_tensor(b)); } -static const std::array op_reg = { +static const C10_UNUSED std::array op_reg = { mobile::prim_op_fn_register("prim::TupleIndex", tupleIndex), mobile::prim_op_fn_register("aten::Bool.Tensor", boolTensor), mobile::prim_op_fn_register("aten::format", aten_format), diff --git a/torch/csrc/jit/passes/pass_manager.cpp b/torch/csrc/jit/passes/pass_manager.cpp index cbd6daa34205db..ed8fe405978b58 100644 --- a/torch/csrc/jit/passes/pass_manager.cpp +++ b/torch/csrc/jit/passes/pass_manager.cpp @@ -3,6 +3,9 @@ namespace torch { namespace jit { +// Start UUID at 1 +static GraphPassNameType graphPassID = 1; + std::vector& getCustomPostPasses() { static std::vector passes; return passes; diff --git a/torch/csrc/jit/passes/pass_manager.h b/torch/csrc/jit/passes/pass_manager.h index e9aeb09e8c0cce..8585c6ecdb3de5 100644 --- a/torch/csrc/jit/passes/pass_manager.h +++ b/torch/csrc/jit/passes/pass_manager.h @@ -26,8 +26,6 @@ using GraphPass = std::function&)>; // Since Passes are std::functions, we associate a UUID to each pass, this way // if we want to deregister a pass, we have something to reference it by. using GraphPassNameType = unsigned int; -// Start UUID at 1 -static GraphPassNameType graphPassID = 1; // Graph pass entries have a name associated with them using GraphPassEntry = std::pair; diff --git a/torch/csrc/jit/runtime/graph_executor.cpp b/torch/csrc/jit/runtime/graph_executor.cpp index 39742c7815d3bc..21d2b714591b3c 100644 --- a/torch/csrc/jit/runtime/graph_executor.cpp +++ b/torch/csrc/jit/runtime/graph_executor.cpp @@ -158,8 +158,8 @@ struct CaptureList { case CAPTURE_LIST: { c10::List lst; auto size = *size_it++; - // NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores,clang-diagnostic-unused-variable) for (const auto i : c10::irange(size)) { + (void)i; lst.emplace_back(var_capture_it->unpack(saved_for)); var_capture_it++; } diff --git a/torch/csrc/jit/runtime/register_c10_ops.cpp b/torch/csrc/jit/runtime/register_c10_ops.cpp index 4d541ec46bbbf1..0c8956f4bdf3e8 100644 --- a/torch/csrc/jit/runtime/register_c10_ops.cpp +++ b/torch/csrc/jit/runtime/register_c10_ops.cpp @@ -54,7 +54,7 @@ Registerer& registerer() { } // global instance to run its constructor on startup -Registerer& dummy = registerer(); +C10_UNUSED Registerer& dummy = registerer(); } // namespace diff --git a/torch/csrc/jit/runtime/script_profile.cpp b/torch/csrc/jit/runtime/script_profile.cpp index 3f43de788ad730..c393dcde1e016b 100644 --- a/torch/csrc/jit/runtime/script_profile.cpp +++ b/torch/csrc/jit/runtime/script_profile.cpp @@ -103,7 +103,7 @@ auto initBindings() { return nullptr; } -const auto torchBindInitializer = initBindings(); +const auto C10_UNUSED torchBindInitializer = initBindings(); } // namespace diff --git a/torch/csrc/jit/tensorexpr/external_functions.cpp b/torch/csrc/jit/tensorexpr/external_functions.cpp index 810fee1c8da873..a77b0a40186e06 100644 --- a/torch/csrc/jit/tensorexpr/external_functions.cpp +++ b/torch/csrc/jit/tensorexpr/external_functions.cpp @@ -25,8 +25,8 @@ std::vector constructTensors( for (const auto i : c10::irange(bufs_num)) { buf_data_vec.push_back(buf_data[i]); buf_dims_vec.emplace_back(); - // NOLINTNEXTLINE(clang-diagnostic-unused-variable,clang-analyzer-deadcode.DeadStores) for (const auto dim : c10::irange(buf_ranks[i])) { + (void)dim; buf_dims_vec[i].push_back(buf_dims[buf_dims_idx++]); } buf_dtypes_vec.push_back(static_cast(buf_dtypes[i])); diff --git a/torch/csrc/jit/tensorexpr/llvm_codegen.cpp b/torch/csrc/jit/tensorexpr/llvm_codegen.cpp index 690edb997bfe76..9e3631deffaf69 100644 --- a/torch/csrc/jit/tensorexpr/llvm_codegen.cpp +++ b/torch/csrc/jit/tensorexpr/llvm_codegen.cpp @@ -1151,9 +1151,6 @@ void LLVMCodeGenImpl::visit(LoadPtr v) { throw std::runtime_error("invalid dtype in Load"); } - // Detect whether the vector mask is all true - bool unmasked_load = true; - // Handle the case where the load is contiguous and unmasked efficiently auto idx_ramp = to(v->flat_index()); if (idx_ramp) { @@ -1805,9 +1802,6 @@ void LLVMCodeGenImpl::visit(IntrinsicsPtr v) { } void LLVMCodeGenImpl::visit(ExternalCallPtr v) { - constexpr int max_buffers = 10; - constexpr int max_dimensions = 40; - auto& func_registry = getNNCFunctionRegistry(); if (!func_registry.count(v->func_name())) { throw unimplemented_lowering(v); diff --git a/torch/csrc/onnx/onnx.h b/torch/csrc/onnx/onnx.h index 4f6860e6026339..d01d8f5e804288 100644 --- a/torch/csrc/onnx/onnx.h +++ b/torch/csrc/onnx/onnx.h @@ -19,7 +19,7 @@ enum class TrainingMode { // We pin IR version instead of using onnx::IR_VERSION so that the // test_operators.py will be more stable. Only bump it when // necessary. -static const size_t IR_VERSION = 7; -static const char* PRODUCER_VERSION = "1.11"; +constexpr size_t IR_VERSION = 7; +constexpr const char* PRODUCER_VERSION = "1.11"; } // namespace onnx } // namespace torch diff --git a/torch/csrc/utils/byte_order.cpp b/torch/csrc/utils/byte_order.cpp index 37dd9ac9b42d10..d720ce689e152f 100644 --- a/torch/csrc/utils/byte_order.cpp +++ b/torch/csrc/utils/byte_order.cpp @@ -236,8 +236,8 @@ void THP_encodeInt16Buffer(uint8_t* dst, const int16_t* src, THPByteOrder order, { memcpy(dst, src, sizeof(int16_t) * len); if (order != THP_nativeByteOrder()) { - // NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores,clang-diagnostic-unused-variable) for(const auto i : c10::irange(len)) { + (void)i; swapBytes16(dst); dst += sizeof(int16_t); } @@ -248,8 +248,8 @@ void THP_encodeInt32Buffer(uint8_t* dst, const int32_t* src, THPByteOrder order, { memcpy(dst, src, sizeof(int32_t) * len); if (order != THP_nativeByteOrder()) { - // NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores,clang-diagnostic-unused-variable) for(const auto i : c10::irange(len)) { + (void)i; swapBytes32(dst); dst += sizeof(int32_t); } @@ -260,8 +260,8 @@ void THP_encodeInt64Buffer(uint8_t* dst, const int64_t* src, THPByteOrder order, { memcpy(dst, src, sizeof(int64_t) * len); if (order != THP_nativeByteOrder()) { - // NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores,clang-diagnostic-unused-variable) for(const auto i : c10::irange(len)) { + (void)i; swapBytes64(dst); dst += sizeof(int64_t); } @@ -272,8 +272,8 @@ void THP_encodeFloatBuffer(uint8_t* dst, const float* src, THPByteOrder order, s { memcpy(dst, src, sizeof(float) * len); if (order != THP_nativeByteOrder()) { - // NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores,clang-diagnostic-unused-variable) for(const auto i : c10::irange(len)) { + (void)i; swapBytes32(dst); dst += sizeof(float); } @@ -284,8 +284,8 @@ void THP_encodeDoubleBuffer(uint8_t* dst, const double* src, THPByteOrder order, { memcpy(dst, src, sizeof(double) * len); if (order != THP_nativeByteOrder()) { - // NOLINTNEXTLINE(clang-analyzer-deadcode.DeadStores,clang-diagnostic-unused-variable) for(const auto i : c10::irange(len)) { + (void)i; swapBytes64(dst); dst += sizeof(double); } diff --git a/torch/csrc/utils/throughput_benchmark-inl.h b/torch/csrc/utils/throughput_benchmark-inl.h index f49cb06d95ef3b..7a11d6f11a3b60 100644 --- a/torch/csrc/utils/throughput_benchmark-inl.h +++ b/torch/csrc/utils/throughput_benchmark-inl.h @@ -64,6 +64,7 @@ BenchmarkExecutionStats BenchmarkHelper::benchmark( // We use conditional variable as a barrier to make sure each thread // performs required warmeup iterations before we start measuring for (const auto j : c10::irange(config.num_warmup_iters)) { + (void)j; runOnce(std::move(thread_inputs[thread_id][input_iters[thread_id]])); ++input_iters[thread_id]; } diff --git a/torch/utils/benchmark/utils/timeit_template.cpp b/torch/utils/benchmark/utils/timeit_template.cpp index 2a57236f2685af..6396d410dec4a5 100644 --- a/torch/utils/benchmark/utils/timeit_template.cpp +++ b/torch/utils/benchmark/utils/timeit_template.cpp @@ -31,6 +31,7 @@ double timeit(int n) { // Main loop auto start_time = std::chrono::high_resolution_clock::now(); for(const auto loop_idx : c10::irange(n)) { + (void)loop_idx; // STMT_TEMPLATE_LOCATION } auto end_time = std::chrono::high_resolution_clock::now(); diff --git a/torch/utils/benchmark/utils/valgrind_wrapper/timer_callgrind_template.cpp b/torch/utils/benchmark/utils/valgrind_wrapper/timer_callgrind_template.cpp index 3a11135638b7f9..1c6bd139a43e4e 100644 --- a/torch/utils/benchmark/utils/valgrind_wrapper/timer_callgrind_template.cpp +++ b/torch/utils/benchmark/utils/valgrind_wrapper/timer_callgrind_template.cpp @@ -44,14 +44,17 @@ int main(int argc, char* argv[]) { // Warmup for(const auto i : c10::irange(number_warmup)) { + (void)i; // STMT_TEMPLATE_LOCATION } // Main loop for(const auto repeat : c10::irange(repeats)) { + (void)repeat; CALLGRIND_TOGGLE_COLLECT; for(const auto i : c10::irange(number)) { + (void)i; // STMT_TEMPLATE_LOCATION }