Repository navigation
Fix tf.tuple() AttributeError for tf.Variable inputs under tf.function - #125420
Merged
copybara-service[bot] merged 1 commit intoAug 21, 2026
Merged
copybara-service[bot] merged 1 commit into
copybara-service[bot] merged 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates 'control_flow_ops.tuple' to explicitly check for 'Tensor' and 'IndexedSlices' instances instead of using 'tensor_util.is_tf_type', and adds a test case to verify repeated variables under 'tf.function'. The review feedback recommends simplifying the new test by returning the tuple directly instead of using 'array_ops.identity' on a list of tensors, which is non-idiomatic and error-prone.
AnupamKumar-1
force-pushed
the
fix-tuple-repeated-variable-125397
branch
from
August 16, 2026 19:17
efb1ebd to
51db2e4
Compare
dmiltr3
self-requested a review
August 17, 2026 15:27
dmiltr3
approved these changes
Aug 17, 2026
Contributor
Author
|
Hi @nithyak0204 , just wanted to check if there’s anything pending for the merge. All checks seem to be passing. |
|
Hi @AnupamKumar-1, This PR is waiting for internal approvals. We are working on it. Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #125397
tuple() skipped ops.convert_to_tensor() for tf.Variable inputs because
tensor_util.is_tf_type() treated them as already graph-safe, leaving
the raw eager handle uncaptured. Calling .op on it then raised
"Tensor.op is undefined when eager execution is enabled" under
tf.function/jit_compile.
Fix: only skip conversion for real Tensor/IndexedSlices instances, so
Variables always go through convert_to_tensor().
Added testRepeatedVariableUnderTFFunction to TupleTestCase covering
the issue's repro.