diff --git a/src/py/backend/backend.py b/src/py/backend/backend.py index 4ad6cc2305d..e2b32a5c984 100755 --- a/src/py/backend/backend.py +++ b/src/py/backend/backend.py @@ -110,7 +110,8 @@ def prepare(cls, model, device=None, **kwargs): "Incompatible device expected '{0}', got '{1}'".format( device, get_device())) inf = migraphx.parse_onnx_buffer(model) - cls._prog_string = str("\nProgram =\n{}".format(inf)) + cls._prog_string = str("\nPython =\n{}\nProgram =\n{}".format( + inf.to_py(), inf)) device = cls._device cls._input_names = inf.get_parameter_names() inf.compile(migraphx.get_target(device.lower())) diff --git a/src/py/migraphx_py.cpp b/src/py/migraphx_py.cpp index 110a9f1ff0d..bafe0fdedf8 100644 --- a/src/py/migraphx_py.cpp +++ b/src/py/migraphx_py.cpp @@ -468,6 +468,12 @@ MIGRAPHX_PYBIND11_MODULE(migraphx, m) migraphx::any_ptr(reinterpret_cast(stream), stream_name), true}; return p.eval(pm, exec_env); }) + .def("to_py", + [](const migraphx::program& p) { + std::stringstream ss; + p.print_py(ss); + return ss.str(); + }) .def("sort", &migraphx::program::sort) .def("print", [](const migraphx::program& p) { std::cout << p << std::endl; }) .def("__eq__", std::equal_to{})