diff --git a/tensorflow/python/kernel_tests/unicode_decode_op_test.py b/tensorflow/python/kernel_tests/unicode_decode_op_test.py index a3dda14900f..6bd9b15af0f 100644 --- a/tensorflow/python/kernel_tests/unicode_decode_op_test.py +++ b/tensorflow/python/kernel_tests/unicode_decode_op_test.py @@ -126,6 +126,8 @@ class UnicodeDecodeTest(test_util.TensorFlowTestCase, {"texts": [["Hi", "there"], ["", u"\U0001f60a"]], "ragged_rank": 0}, {"texts": [["Hi", "there", ""], [u"😊"]], "ragged_rank": 1}, {"texts": [[[u"😊", u"🤠🧐"], []], [[u"🤓👻🤖"]]], "ragged_rank": 2}, + {"texts": [[[u"😊"], [u"🤠🧐"]], [[u"🤓👻🤖"]]], "ragged_rank": 1}, + {"texts": [[[u"😊"], [u"🤠🧐"]], [[u"🤓"], [u"👻"]]], "ragged_rank": 0}, {"texts": []} ]) # pyformat: disable def testBasicDecode(self, texts, ragged_rank=None): diff --git a/tensorflow/python/ops/ragged/ragged_string_ops.py b/tensorflow/python/ops/ragged/ragged_string_ops.py index 493e5b97cd6..d5f21832044 100755 --- a/tensorflow/python/ops/ragged/ragged_string_ops.py +++ b/tensorflow/python/ops/ragged/ragged_string_ops.py @@ -411,7 +411,7 @@ def _unicode_decode(input, input_encoding, errors, replacement_char, input = input.with_flat_values( ragged_tensor.RaggedTensor.from_tensor( input.flat_values, - ragged_rank=input_ndims - input.ragged_rank + 1)) + ragged_rank=input_ndims - input.ragged_rank - 1)) # Reshape the input to a flat vector, and apply the gen_string_ops op. if ragged_tensor.is_ragged(input):