turn on -Werror=unused-function in our Bazel CPU build

Summary:
We also fix any existing issues. Note that we only do this for the CPU
build because nvcc is considered a C++ toolchain but it does not have
the same flag support. Adding flags to the GPU build will cause nvcc
errors.

Test Plan: Built locally, rely on CI to confirm.

Reviewers: malfet

Subscribers:

Tasks:

Tags:

Pull Request resolved: https://github.com/pytorch/pytorch/pull/79154

Approved by: https://github.com/seemethere, https://github.com/osalpekar, https://github.com/albanD
This commit is contained in:
Michael Andreas Dagitses
2022-06-09 13:15:50 -07:00
committed by PyTorch MergeBot
parent 3734fcc8f8
commit 67d313a032
26 changed files with 82 additions and 372 deletions
+21 -20
View File
@@ -34,29 +34,30 @@ void testEvalModeForLoadedModule() {
AT_ASSERT(module.attr("dropout").toModule().is_training());
}
void testSerializationInterop() {
if (isSandcastle()) {
// The module file to load is not generated in Sandcastle
return;
}
// TODO: this test never ran before and is broken.
// void testSerializationInterop() {
// if (isSandcastle()) {
// // The module file to load is not generated in Sandcastle
// return;
// }
// This should be generated by `test/cpp/jit/tests_setup.py`
std::ifstream input_stream("ivalue.pt");
std::vector<char> input;
input.insert(
input.begin(),
std::istream_iterator<char>(input_stream),
std::istream_iterator<char>());
IValue ivalue = pickle_load(input);
// // This should be generated by `test/cpp/jit/tests_setup.py`
// std::ifstream input_stream("ivalue.pt");
// std::vector<char> input;
// input.insert(
// input.begin(),
// std::istream_iterator<char>(input_stream),
// std::istream_iterator<char>());
// IValue ivalue = pickle_load(input);
auto elements = ivalue.toTupleRef().elements();
auto ones = torch::ones({2, 2});
AT_ASSERT(ones.equal(elements.at(0).toTensor()));
// auto elements = ivalue.toTupleRef().elements();
// auto ones = torch::ones({2, 2});
// AT_ASSERT(ones.equal(elements.at(0).toTensor()));
// NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers)
auto twos = torch::ones({3, 5}) * 2;
AT_ASSERT(twos.equal(elements.at(1).toTensor()));
}
// // NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers)
// auto twos = torch::ones({3, 5}) * 2;
// AT_ASSERT(twos.equal(elements.at(1).toTensor()));
// }
void testTorchSaveError() {
if (isSandcastle()) {