pytorch/torch/csrc/jit/script/init.cpp
Adam Paszke a0118533ef
Add a print() function to the JIT script (#5274)
Additionally:
- add support for calling functions that are not methods in the Python frontend
- add an end-to-end test for the Python frontend
- add a capture_stdout helper for checking that `print` actually works
2018-02-24 11:15:55 +01:00

21 lines
584 B
C++

#include "torch/csrc/jit/script/init.h"
#include "torch/csrc/jit/script/compiler.h"
namespace torch {
namespace jit {
namespace script {
void initJitScriptBindings(PyObject* module) {
auto m = py::handle(module).cast<py::module>();
py::class_<CompilationUnit>(m, "CompilationUnit")
.def(py::init<>())
.def("get_graph", &CompilationUnit::getGraph,
py::return_value_policy::reference)
.def("define_function", &CompilationUnit::defineFunction);
m.def("_jit_script_compile", jitScriptCompile);
}
} // namespace script
} // namespace jit
} // namespace torch