Preserve dynamic shape expressions through constant folding - #22
Merged
stevenvar merged 11 commits intoJul 29, 2026
Conversation
stevenvar
force-pushed
the
steven.partial_symbolic_const_folding
branch
5 times, most recently
from
April 27, 2026 10:49
74663cc to
3cda438
Compare
stevenvar
pushed a commit
that referenced
this pull request
Jul 7, 2026
resolve the issue for the xla batch matcher flag is set but invalid
stevenvar
force-pushed
the
steven.partial_symbolic_const_folding
branch
from
July 29, 2026 13:47
b108667 to
0bd94c3
Compare
stevenvar
force-pushed
the
steven.partial_symbolic_const_folding
branch
from
July 29, 2026 15:25
e5d3302 to
129f751
Compare
stevenvar
added a commit
that referenced
this pull request
Aug 5, 2026
stevenvar
added a commit
that referenced
this pull request
Aug 12, 2026
stevenvar
added a commit
that referenced
this pull request
Aug 12, 2026
stevenvar
added a commit
that referenced
this pull request
Aug 12, 2026
stevenvar
added a commit
that referenced
this pull request
Aug 12, 2026
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.
Summary
This PR preserves dynamic shape expressions when TensorFlow partially evaluates shape-derived values and replaces them with constants. Without this metadata, XLA sees only the concrete value used during compilation and can lose the relationship with the dynamic input size.
The change:
Shape,Slice,StridedSlice,Gather,Reshape,Pack,ConcatV2, andProd;Constnodes and restores them when building XLA constants and compile-time arguments;Tests
FoldShapeFromDynamicArgPreservesContents: keeps the expressions produced byShape.FoldSliceOfDynamicShapePreservesContents: keeps the selected dynamic dimension throughSlice.FoldGatherOfDynamicShapePreservesContents: keeps a gathered dynamic dimension in a scalar result.FoldReshapeOfDynamicShapePreservesContents: keeps symbolic contents when a one-element vector is reshaped to a scalar.FoldPackOfDynamicShapePreservesContents: keeps dynamic and static entries when they are packed into one shape tensor.DoNotFoldUnsupportedDynamicContentsTransform: leaves unsupported transformations unfurled instead of dropping their expressions.NoReplacePartialOutput: checks that non-CPU multi-output operations are not partially replaced.