Skip to content
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
wants to merge 16 commits into
base: main
Choose a base branch
from
Draft

Conversation

jacobhinkle
Copy link
Collaborator

@jacobhinkle jacobhinkle commented Jun 22, 2023

As discussed in #460 and #439, start & stop arguments to slice 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 a set or full (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.

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 jacobhinkle changed the title Concretize dynamic slices Simplify slice expressions at concretization Sep 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant