Enable Wno-unused-private-field,Wunused-lambda-capture and fix CUDA warnings (#110856)

This PR enables Wno-unused-private-field,Wunused-lambda-capture  and some CUDA warnings were fixed.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/110856
Approved by: https://github.com/albanD, https://github.com/malfet
This commit is contained in:
cyy 2023-10-25 03:39:05 +00:00 committed by PyTorch MergeBot
parent 9e6c97890b
commit f9cc7f6a1c
8 changed files with 5 additions and 28 deletions

View File

@ -894,10 +894,8 @@ if(NOT MSVC)
append_cxx_flag_if_supported("-Wno-error=inconsistent-missing-destructor-override" CMAKE_CXX_FLAGS)
append_cxx_flag_if_supported("-Wconstant-conversion" CMAKE_CXX_FLAGS)
append_cxx_flag_if_supported("-Wno-invalid-partial-specialization" CMAKE_CXX_FLAGS)
append_cxx_flag_if_supported("-Wno-unused-private-field" CMAKE_CXX_FLAGS)
append_cxx_flag_if_supported("-Wno-aligned-allocation-unavailable" CMAKE_CXX_FLAGS)
append_cxx_flag_if_supported("-Wno-missing-braces" CMAKE_CXX_FLAGS)
append_cxx_flag_if_supported("-Wunused-lambda-capture" CMAKE_CXX_FLAGS)
append_cxx_flag_if_supported("-Qunused-arguments" CMAKE_CXX_FLAGS)
if(${USE_COLORIZE_OUTPUT})

View File

@ -142,15 +142,11 @@ TORCH_IMPL_FUNC(fractional_max_pool2d_out_cuda) (
fractional_max_pool_check_shape</*ndim*/ 2>(input, randomSamples);
int planeDim = 0;
int dimh = 1;
int dimw = 2;
int ndims = input.ndimension();
if (ndims == 4) {
planeDim++;
dimh++;
dimw++;
}
/* sizes */

View File

@ -367,7 +367,7 @@ computeLinearIndex(const Tensor & src, TensorList indices, bool check_range) {
// this point. We also compute the number of dimensions before and after that
// are not being index.
Tensor linearIndex;
int64_t emptyBefore = 0, emptyAfter = 0, nElemBefore = 1, nElemAfter = 1, strideBefore =0;
int64_t nElemBefore = 1, nElemAfter = 1, strideBefore =0;
for (const auto i: c10::irange(src.dim())) {
if (indices[i].defined()) {
// Cast index to the longType matching src's device
@ -382,10 +382,8 @@ computeLinearIndex(const Tensor & src, TensorList indices, bool check_range) {
}
}
} else if (linearIndex.defined()) {
emptyAfter++;
nElemAfter *= src.size(i);
} else {
emptyBefore++;
nElemBefore *= src.size(i);
}
}

View File

@ -242,13 +242,11 @@ void replication_pad2d_backward_out_cuda_template(
const auto padR = paddingSize[1];
const auto padT = paddingSize[2];
const auto padB = paddingSize[3];
int planeDim = 0;
int dimh = 1;
int dimw = 2;
int numInputDims = input.dim();
if (numInputDims == 4) {
planeDim++;
dimh++;
dimw++;
}
@ -376,18 +374,8 @@ void replication_pad3d_backward_out_cuda_template(
shapeAndGradOutputCheck3d(input, gradOutput, pleft, pright, ptop,
pbottom, pfront, pback);
int planeDim = 0;
int dimd = 1;
int dimh = 2;
int dimw = 3;
int numInputDims = input.dim();
if (numInputDims == 5) {
planeDim++;
dimd++;
dimh++;
dimw++;
}
gradInput.resize_as_(input);
if (gradInput.numel() == 0) {
@ -498,12 +486,10 @@ TORCH_IMPL_FUNC(replication_pad1d_backward_out_cuda) (
"output gradient tensor must fit into 32-bit index math");
const int padL = paddingSize[0];
int planeDim = 0;
int dimw = 1;
int numInputDims = input.ndimension();
if (numInputDims == 3) {
planeDim++;
dimw++;
}
int iwidth = input.size(dimw);

View File

@ -964,6 +964,7 @@ elseif(USE_CUDA)
endif()
set(CUDA_LINK_LIBRARIES_KEYWORD)
torch_compile_options(torch_cuda) # see cmake/public/utils.cmake
target_compile_options_if_supported(torch_cuda "-Wno-deprecated-copy") # see cmake/public/utils.cmake
target_compile_definitions(torch_cuda PRIVATE USE_CUDA)
if(USE_CUSPARSELT)

View File

@ -23,9 +23,7 @@ class TestLeafNode : public Node {
}
explicit TestLeafNode(size_t param)
: Node(ClassOpKind(), /* num_outputs */ 1),
hash_(Hash(param)),
param_(param) {}
: Node(ClassOpKind(), /* num_outputs */ 1), hash_(Hash(param)) {}
~TestLeafNode() override = default;
const std::vector<Output>& operands() const override {
@ -45,7 +43,6 @@ class TestLeafNode : public Node {
private:
hash_t hash_;
size_t param_;
};
TEST(IrTest, BasicTest) {

View File

@ -4,6 +4,8 @@ set(TORCH_ROOT ${CMAKE_CURRENT_LIST_DIR}/../..)
set(TEST_ROOT ${TORCH_ROOT}/test/edge)
set(OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out)
file(GLOB_RECURSE all_python "${TORCH_ROOT}/torchgen/*.py")
include(${TORCH_ROOT}/cmake/public/utils.cmake)
append_cxx_flag_if_supported("-Wno-unused-private-field" CMAKE_CXX_FLAGS)
# Generate unboxing kernels
set(GEN_COMMAND

View File

@ -3095,7 +3095,6 @@ TEST_F(NVFuserTest, FusionPredRemovalCheck_CUDA) {
}
private:
bool within_ite_ = false;
} pred_checker;
GpuLower gpulw(&fusion);