Skip to content
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

tf.raw_ops.StringSplitV2 does not limit a number of splits by max_split attribute #66583

Open
rkazants opened this issue Apr 28, 2024 · 3 comments
Assignees
Labels
comp:ops OPs related issues TF 2.16 type:bug Bug

Comments

@rkazants
Copy link

Issue type

Bug

Have you reproduced the bug with TensorFlow Nightly?

Yes

Source

source

TensorFlow version

2.16.1

Custom code

Yes

OS platform and distribution

No response

Mobile device

No response

Python version

No response

Bazel version

No response

GCC/compiler version

No response

CUDA/cuDNN version

No response

GPU model and memory

No response

Current behavior?

tf.raw_ops.StringSplitV2 does not limit a number of splits by max_split attribute.

Standalone code to reproduce the issue

import tensorflow as tf

tf.raw_ops.StringSplitV2(input=['one<>'], sep='<>', maxsplit=1) # outputs two splits 'one' and '' instead of just one split

tf.raw_ops.StringSplitV2(input=['one<>two'], sep='<>', maxsplit=1) # outputs two splits 'one' and 'two' instead of just one split

Relevant log output

>>> tf.raw_ops.StringSplitV2(input=['one<>'], sep='<>', maxsplit=1)
StringSplitV2(indices=<tf.Tensor: shape=(2, 2), dtype=int64, numpy=
array([[0, 0],
       [0, 1]])>, values=<tf.Tensor: shape=(2,), dtype=string, numpy=array([b'one', b''], dtype=object)>, shape=<tf.Tensor: shape=(2,), dtype=int64, numpy=array([1, 2])>)

>>> tf.raw_ops.StringSplitV2(input=['one<>two'], sep='<>', maxsplit=1)
StringSplitV2(indices=<tf.Tensor: shape=(2, 2), dtype=int64, numpy=
array([[0, 0],
       [0, 1]])>, values=<tf.Tensor: shape=(2,), dtype=string, numpy=array([b'one', b'two'], dtype=object)>, shape=<tf.Tensor: shape=(2,), dtype=int64, numpy=array([1, 2])>)
@sushreebarsa
Copy link
Contributor

@rkazants I was able to replicate the issue reported here. Could you consider using tf.strings.split instead. It offers an optional max_split parameter to limit the number of splits: https://www.tensorflow.org/api_docs/python/tf/strings/split
Thank you!

@sushreebarsa sushreebarsa added the stat:awaiting response Status - Awaiting response from author label May 7, 2024
Copy link

This issue is stale because it has been open for 7 days with no activity. It will be closed if no further activity occurs. Thank you.

@github-actions github-actions bot added the stale This label marks the issue/pr stale - to be closed automatically if no activity label May 15, 2024
@rkazants
Copy link
Author

Hi @sushreebarsa,

please remove stale label because the issue is not fixed.

Best regards,
Roman

@google-ml-butler google-ml-butler bot removed stale This label marks the issue/pr stale - to be closed automatically if no activity stat:awaiting response Status - Awaiting response from author labels May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:ops OPs related issues TF 2.16 type:bug Bug
Projects
None yet
Development

No branches or pull requests

3 participants