[TorchScript] bindings for torch._C.ClassType.method_names() (#140444)

I used this for debugging, figured I'd upstream it.

This gives you a list of the method names provided by the given ClassType.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/140444
Approved by: https://github.com/eellison
This commit is contained in:
David Berard 2024-11-12 12:11:03 -08:00 committed by PyTorch MergeBot
parent 2675ef8758
commit 1a8752bc7d

View File

@ -1071,8 +1071,15 @@ void initPythonIRBindings(PyObject* module_) {
return get_python_cu()->get_class(c10::QualifiedName(qualified_name));
}))
.def("name", [](ClassType& self) { return self.name()->name(); })
.def("qualified_name", [](ClassType& self) {
return self.name()->qualifiedName();
.def(
"qualified_name",
[](ClassType& self) { return self.name()->qualifiedName(); })
.def("method_names", [](ClassType& self) {
std::vector<std::string> method_names;
for (const auto* method : self.methods()) {
method_names.push_back(method->name());
}
return method_names;
});
py::class_<EnumType, Type, EnumTypePtr>(m, "EnumType")
.def(py::init([](const std::string& qualified_name,