mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
[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:
parent
2675ef8758
commit
1a8752bc7d
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user