Skip to content

Commit

Permalink
Print python from onxx backend test (#3672)
Browse files Browse the repository at this point in the history
  • Loading branch information
pfultz2 authored Dec 5, 2024
1 parent 6f75e62 commit 2e9104a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/py/backend/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down
6 changes: 6 additions & 0 deletions src/py/migraphx_py.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,12 @@ MIGRAPHX_PYBIND11_MODULE(migraphx, m)
migraphx::any_ptr(reinterpret_cast<void*>(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<migraphx::program>{})
Expand Down

0 comments on commit 2e9104a

Please sign in to comment.