Add ScatterOp no-op simplification patterns#2920
Open
brucechanglongxu wants to merge 1 commit intoopenxla:mainfrom
Open
Add ScatterOp no-op simplification patterns#2920brucechanglongxu wants to merge 1 commit intoopenxla:mainfrom
brucechanglongxu wants to merge 1 commit intoopenxla:mainfrom
Conversation
Two new patterns in StablehloAggressiveSimplification: - ScatterOpEmptyIndices: when scatter_indices has zero scatter points along any non-index_vector_dim axis, the scatter is a no-op and the inputs pass through unchanged. - ScatterOpZeroExtentUpdates: when all update tensors have zero elements, the scatter does nothing. Both follow the existing convention for no-op detection (cf. DynamicUpdateSliceOp_RemoveNoop, ConcatenateOpRemoveEmpty). Toward openxla#2736
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.
ScatterOp had zero simplification patterns — even trivially dead
scatters were being left in the IR. This adds two no-op patterns to
StablehloAggressiveSimplification:
ScatterOpEmptyIndices — scatter_indices has no scatter points (a
non-index_vector_dim axis is 0), so nothing gets scattered. The
inputs pass through.
ScatterOpZeroExtentUpdates — all update tensors have zero elements,
same result.
These mirror the existing DynamicUpdateSliceOp_RemoveNoop /
ConcatenateOpRemoveEmpty patterns. More interesting patterns (e.g.
full-replace folding when the update body is a trivial return of arg1)
can come later, but these two cover the low-hanging fruit.
Tests included for both patterns plus a negative case to make sure we
don't over-simplify.
Toward #2736