-
Notifications
You must be signed in to change notification settings - Fork 74k
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
fix character access in autograph #21580
Conversation
@mdanatg could you take a look? |
Nagging Reviewer @mdanatg: You have been added as a reviewer to this pull request. Please add your review or reassign. It has been 16 days with no activity and the |
This is great! Sorry for the delay, I just got back from vacation. |
@@ -46,6 +46,19 @@ def test_get_item_tensor_list(self): | |||
with self.test_session() as sess: | |||
self.assertAllEqual(sess.run(t), [3, 4]) | |||
|
|||
def test_get_item_tensor_string(self): | |||
initial_str = constant_op.constant("abcd") |
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.
For consistency, please use single quotation marks for single-line strings.
@mdanatg you are right, fixed. |
I just realized this will raise error for tensor of string. This should only apply for string with rank 0. |
@@ -58,7 +58,7 @@ def get_item(target, i, opts): | |||
elif tensor_util.is_tensor(target): | |||
if target.dtype == dtypes.variant: | |||
return _tf_tensor_list_get_item(target, i, opts) | |||
if target.dtype == dtypes.string: | |||
elif target.dtype == dtypes.string and target.get_shape() == (): # target is string with rank 0 |
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.
More idiomatic: target.shape.ndims == 0
https://www.tensorflow.org/api_docs/python/tf/TensorShape#ndims
PiperOrigin-RevId: 212122272
fix #20703 by extending the tensor index operator.