-
Notifications
You must be signed in to change notification settings - Fork 52
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
Simplify slice expressions at concretization #511
Draft
jacobhinkle
wants to merge
16
commits into
main
Choose a base branch
from
dynamic_slice
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains 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
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].
jacobhinkle
changed the title
Concretize dynamic slices
Simplify slice expressions at concretization
Sep 26, 2023
This was referenced Aug 19, 2024
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
&stop
arguments toslice
must 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 aset
orfull
(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
SliceOp
for the purposes of determining the slice concretization branches.Fixes #439. Fixes #52.