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

Some slice fixes #37

Merged
merged 7 commits into from
May 25, 2023
Merged

Conversation

mgehre-amd
Copy link
Collaborator

@mgehre-amd mgehre-amd commented May 25, 2023

This mostly comes from TOSA having very strong requirements of start/end in slices
For pytorch, start and end can be larger than the dimension size, and they are than clamped to the size of the dimension.

ramiro050 and others added 3 commits May 25, 2023 12:56
The `copy_` op being replaced by `RecomposeSliceCopy_` operates on a
subset of the tensor being mutated, while the `index_put` op being
used to replace the `copy_` op operates on the entire tensor being
mutated. This means that the result type of the `index_put` should be
the type of the input to `index_put` and we need to make sure that
`copy_` does not have users before replacing to avoid type conflicts.

Note: this commit fixes a type conflict that only seems to arise when
`use_tracing=True`, since normally the recomposition happens before
type propagation takes place. Since the e2e testing framework does not
do tracing, here we use a lit test to check correctness.
When `use_tracing=True` is used to import a model into Torch-MLIR,
several casts get inserted in the IR to bridge the untyped inputs and
outputs with the typed body of the computation. These casts create
extra aliases of tensors that cause the current analysis in
`maximize-value-semantics` to fail.

In particular, the `maximize-value-semantics` analysis assumes that the
only valid alias right after an overwrite is the overwritten
alias. So, if there is a use of a casted version of the overwritten
alias after the overwrite, the analysis fails.

This commit improves the analysis by identifying all cast-like aliases
of the overwritten alias and allowing such aliases to be used after an
overwrite.

Because this issue only arises when using tracing, it cannot be
currently tested e2e, so only lit test is added.
@mgehre-amd mgehre-amd enabled auto-merge (squash) May 25, 2023 13:09
@mgehre-amd mgehre-amd merged commit 205a76e into feature/misc_fixes May 25, 2023
@mgehre-amd mgehre-amd deleted the matthias.some_slice_fixes branch May 25, 2023 14:23
@mgehre-amd mgehre-amd mentioned this pull request Jun 5, 2023
51 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants