Simplify slice expressions at concretization#511
Draft
jacobhinkle wants to merge 16 commits intomainfrom
Draft
Conversation
Should use id->extent()->isConstInt() instead.
This is in lieu of replacing all uses of symbolic extents, which cannot be done reliably since they might appear as attributes or members of objects which are untracked. See #420
This lets us process ops in topological order instead of doing all reshapes followed by all slices etc. This is very helpful since we need to evaluate vals that are not defined until their upstream ops are concretized.
Previously we concretized all reshapes then all slices then all resizes. This failed the FusionSliceForNanoGPT3_CUDA test which has the slice->reshape->slice->reshape pattern, since we were concretizing reshapes that had inputs which were not yet concretized and which actually needed to be replaced. Since concretization of slices and reshapes can actually replace a TensorView, we need to ensure that those are done in the correct order.
This will remove more trivial slices, but means we trigger a recompile between x[0:m] and x[1:m].
This was referenced Aug 19, 2024
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.
As discussed in #460 and #439,
start&stoparguments toslicemust be normalized, resulting in complicated branching expressions. In this PR, we make slices dynamic and decide the branches for these expressions at concretization, which lets us simplify the expressions. In some special cases this also lets us replace the slice with asetorfull(for empty tensors).NOTE: since #460 uses proper expressions for slice ranges, the original unnormalized expressions can be hard to find. This PR will need to either carefully unwrap those expressions or attach the original expressions to the
SliceOpfor the purposes of determining the slice concretization branches.Fixes #439. Fixes #52.