Skip to content

Commit

Permalink
add -Wnarrowing as error to cmake builds (pytorch#89207)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikey dagitses authored and pytorchmergebot committed Nov 18, 2022
1 parent fd0efb0 commit 92f9214
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,6 @@ endif()
# ---[ Build flags
if(NOT MSVC)
string(APPEND CMAKE_CXX_FLAGS " -O2 -fPIC")
string(APPEND CMAKE_CXX_FLAGS " -Wno-narrowing")
# Eigen fails to build with some versions, so convert this to a warning
# Details at http://eigen.tuxfamily.org/bz/show_bug.cgi?id=1459
string(APPEND CMAKE_CXX_FLAGS " -Wall")
Expand All @@ -824,6 +823,7 @@ if(NOT MSVC)
append_cxx_flag_if_supported("-Werror=non-virtual-dtor" CMAKE_CXX_FLAGS)
append_cxx_flag_if_supported("-Werror=braced-scalar-init" CMAKE_CXX_FLAGS)
append_cxx_flag_if_supported("-Werror=range-loop-construct" CMAKE_CXX_FLAGS)
append_cxx_flag_if_supported("-Wnarrowing" CMAKE_CXX_FLAGS)
append_cxx_flag_if_supported("-Wno-missing-field-initializers" CMAKE_CXX_FLAGS)
append_cxx_flag_if_supported("-Wno-type-limits" CMAKE_CXX_FLAGS)
append_cxx_flag_if_supported("-Wno-array-bounds" CMAKE_CXX_FLAGS)
Expand Down
4 changes: 2 additions & 2 deletions aten/src/ATen/native/NNPACK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ Tensor _nnpack_spatial_convolution(
.height = (size_t)output.size(2),
};
const nnp_size output_subsample = {
.width = stride[1],
.height = stride[0],
.width = static_cast<std::size_t>(stride[1]),
.height = static_cast<std::size_t>(stride[0]),
};

const auto input_ = input.contiguous();
Expand Down
2 changes: 1 addition & 1 deletion aten/src/ATen/native/mps/operations/Distributions.mm
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ Tensor normal_mps(const Tensor& mean, const Tensor& std, c10::optional<Generator
MPSGraphTensor *randomTensor = generatorTensors[0];

auto broadcastShape = @[ns_numDist ,ns_n_sample, ns_numCategories];
int broadcastShapeVals[3] = {numDist, n_sample, numCategories};
int broadcastShapeVals[3] = {numDist, static_cast<int>(n_sample), numCategories};
MPSGraphTensor *broadcastShapeTensor = [mpsGraph constantWithData:[NSData dataWithBytes:broadcastShapeVals length:sizeof(int) * broadcastShape.count]
shape:@[[NSNumber numberWithUnsignedInteger:broadcastShape.count]]
dataType:MPSDataTypeUInt32];
Expand Down

0 comments on commit 92f9214

Please sign in to comment.