-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[Debugger Plugin] Fix bugs related to binary string tensors #1200
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
* Binary strings (strings that cannot be encoded in JSON, as is the case with output tensors of Summary ops) is now converted to a printable format using Python's `binascii.b2a_qp()`. * To prevent overloading the frontend and frontend-backend communication, long string elements are truncated at 40 bytes. * Display dtype 'object' as 'string' for clarity.
|
@chihuahua See screenshot for the effect of this CL. |
|
@chihuahua @nfelt It seems that the Travis test jobs are failing for unrelated reasons:
|
|
If you run This is a known issue. Kokoro switched to GCC 4.9 because NVidia and Docker, which isn't compatible with RHEL, CentOS, Ubuntu14, Travis, etc. I got them to reconsider that decision last week. We're still waiting on the new nightlies to go live. The same thing happened back in January. I'm reaching that point where I'm about to roll my own binaries. Would you support me? |
chihuahua
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.
Thank you Shanqing for fixing this bug!
| def translate_dtype(dtype): | ||
| """Translate numpy dtype into a string. | ||
| The 'object' type is understood as a tenosrflow string and translated into |
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.
nit: TensorFlow
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.
Done.
| """Process a buffer for human-readable display. | ||
| This function performs the following operation on each of the buffers in `s`. | ||
| 1. Truncate input buffer if the length of the buffer is greater than |
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.
Maybe briefly offer some rationale on why we truncate in the first place.
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.
Done.
| length = len(s) | ||
| if length > limit: | ||
| return (binascii.b2a_qp(s[:limit]) + | ||
| b' (length-%s truncated at %s bytes)' % (length, limit)) |
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.
nit: I think both should be %ds.
| length = len(s) | ||
| if length > limit: | ||
| return (binascii.b2a_qp(s[:limit]) + | ||
| b' (length-%s truncated at %s bytes)' % (length, limit)) |
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.
also nit: Any reason for this to be a binary string specifically (prefixed with b')?
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.
This is for Python2-3 compatibility. Without the b, the string will end up being a unicode string in Python3 and cannot be concatenated with the output of binascii.b2a_qp.
caisq
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.
Thanks a lot for the review! @chihuahua
| def translate_dtype(dtype): | ||
| """Translate numpy dtype into a string. | ||
| The 'object' type is understood as a tenosrflow string and translated into |
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.
Done.
| """Process a buffer for human-readable display. | ||
| This function performs the following operation on each of the buffers in `s`. | ||
| 1. Truncate input buffer if the length of the buffer is greater than |
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.
Done.
| length = len(s) | ||
| if length > limit: | ||
| return (binascii.b2a_qp(s[:limit]) + | ||
| b' (length-%s truncated at %s bytes)' % (length, limit)) |
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.
This is for Python2-3 compatibility. Without the b, the string will end up being a unicode string in Python3 and cannot be concatenated with the output of binascii.b2a_qp.
|
@jart thanks for the info on the test failures. I've run the tests and made sure the tests all pass under both py2 and py3. So I'll merge the PR now. @chihuahua Thanks again for your review!! |
|
@jart This PR is ready for merging. |
|
I feel guilty merging when Travis is red, but it appears to be a pylint error, and we just removed that in #1207. |
|
Thanks, @jart! |

with output tensors of Summary ops) are now converted to a printable
format using Python's
binascii.b2a_qp().communication, long string elements are truncated at 40 bytes.