-
Notifications
You must be signed in to change notification settings - Fork 26.3k
[JIT] Override print when python is present #21625
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
facebook-github-bot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jamesr66a has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
| namespace torch { | ||
| namespace jit { | ||
|
|
||
| using PrintHandler = void (*)(const std::string&); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nah brah
torch/csrc/jit/init.cpp
Outdated
| // WriteStdout will truncate to 1000 bytes. | ||
| // auto _stdout = py::module::import("sys").attr("stdout"); | ||
| // _stdout.attr("write")(_stdout, str); | ||
| PySys_WriteStdout("%s", str.c_str()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we not just call print through pybind?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't get it to not complain that it expects bytes, not str, even if i explicitly cast to py::bytes. something seems broken there in pybind
ab38165 to
d089ea3
Compare
facebook-github-bot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jamesr66a has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
dd56ec0 to
90c0674
Compare
facebook-github-bot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jamesr66a has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
facebook-github-bot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jamesr66a has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
facebook-github-bot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jamesr66a is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
|
@jamesr66a merged this pull request in c2a18a6. |
This makes it so we can see the output of prim::Print in environments like iPython notebooks which override sys.stdout