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
gdb special command to print tensors #54339
Conversation
|
PyGILState_Release(gil); | ||
return result; | ||
|
||
error: |
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.
Not using RAII here is kind of weird. Is there a particular reason, e.g., gdb doesn't like it when you have stack unwinding?
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.
the most honest answer is that I am used to write Python API code in C and I didn't think that this was C++
But also, I am not aware of any standard smart-pointer-like class to manage PyObject*
in C++ with RAII. Do we have any helper for that?
Or you were suggesting do write a custom class just to handle this specific function?
@ezyang has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
I saw the tool (pytorhc-gdb), so I want to have a try.
I built pytorch from source with "DEBUG=1", I'm not sure if I use the tool correctly. |
you are correct, the example was out of date. I fixed it in #61175 |
…1175) Summary: As pointed out by #54339 (comment), the `pytorch-gdb` example is currently broken because the code has been refactored. This PR updates the example so that it works again. Pull Request resolved: #61175 Reviewed By: heitorschueroff Differential Revision: D29660336 Pulled By: ezyang fbshipit-source-id: 8bcd32fc583c0b28a705ef37203ce7ad4d636732
This is something which I wrote because it was useful during my debugging sessions, but I think it might be generally useful to other people as well so I took the liberty of proposing an official
pytorch-gdb
extension.pytorch-gdb
is a gdb script written in python. Currently, it contains only one command:torch-tensor-repr
, which prints a human-readable repr of anat::Tensor
object. Example:The idea is that by having an official place where to put these things,
pytorch-gdb
will slowly grow other useful features and make the pytorch debugging experience nicer and faster.