Template Function torch::python::add_module_bindings

Function Documentation

template<typename ModuleType, typename ...Extra>
py::class_<ModuleType, Extra...> torch::python::add_module_bindings(py::class_<ModuleType, Extra...> module)

Adds method bindings for a pybind11 class_ that binds an nn::Module subclass.

Say you have a pybind11 class object created with py::class_<Net>(m, "Net"). This function will add all the necessary .def() calls to bind the nn::Module base class’ methods, such as train(), eval() etc. into Python.

Users should prefer to use bind_module if possible.


Access comprehensive developer documentation for PyTorch

View Docs


Get in-depth tutorials for beginners and advanced developers

View Tutorials


Find development resources and get your questions answered

View Resources