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

View File

@ -345,17 +345,6 @@ void pushMobileFunctionsToIValues(
}
}
std::unordered_set<const FunctionSchema*> getInterfaceCalls(Graph& graph) {
std::unordered_set<const FunctionSchema*> ret;
auto nodes = findAllNodes(graph, c10::prim::CallMethod, true);
for (Node* node : nodes) {
if (auto iface = node->input(0)->type()->castRaw<InterfaceType>()) {
ret.insert(iface->getMethod(node->s(attr::name)));
}
}
return ret;
}
struct ModuleMethod {
ModuleMethod(const Module& m, const GraphFunction& f, c10::QualifiedName n)
: module(m), function(f), exportName(std::move(n)) {}
@ -364,28 +353,6 @@ struct ModuleMethod {
c10::QualifiedName exportName;
};
std::vector<ModuleMethod> getModuleInterfaceExports(
const Module& module,
const std::unordered_set<const FunctionSchema*>& schemas) {
if (schemas.size() == 0) {
return {};
}
std::unordered_set<std::string> names;
for (auto schema : schemas) {
names.insert(schema->name());
}
std::vector<ModuleMethod> ret;
for (const auto& submodule : module.modules()) {
for (const auto& method : submodule.get_methods()) {
const auto& f = toGraphFunction(method.function());
if (names.find(f.qualname().name()) != names.end()) {
ret.emplace_back(submodule, f, f.qualname());
}
}
}
return ret;
}
bool isLoweredModule(const Module& m) {
c10::QualifiedName type_name;
if (m.type()->name()) {