At the moment, they are a part of EmptyOp::getCanonicalizationPatterns. When
extract_slice(tensor.empty) is rewritten as a new tensor.empty, it could
happen that we end up with two tensor.empty ops, since the original
tensor.empty can have two users. After bufferization such cases result in two
allocations.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
This looks good to me. Do you mind holding off landing it till I can fix downstream users?
mlir/lib/Dialect/Tensor/IR/TensorOps.cpp | ||
---|---|---|
623 | You shouldnt need this pattern also actually (just FYI, no need to do it here). This happens as part of handling dims using InferRankedShapedTypeResultDims interface. |
Thanks @mravishankar. Sure, it can wait.
mlir/lib/Dialect/Tensor/IR/TensorOps.cpp | ||
---|---|---|
623 | I'll clean it up later then. |
Sorry for the delay and thanks for your patience. https://github.com/iree-org/iree/pull/11452 should see if there are any IREE issues. If that passes, I will stamp it here.
Sorry, wrong link. This is the PR that tests this patch in IREE https://github.com/iree-org/iree/pull/11454
There are some failures downstream.... I will have to look into this, Ill try to take a look soon, but do you mind waiting till I resolve the issues first?
Looking through this I think maybe some patterns are indeed canonicalization. The empty -> slice folding pattern indeed isnt a canonicalization. Same is true for the empty -> reshape patterns maybe (though it could go either way I think). Marking as request changes since I think the empty -> cast pattern is a legit canonicalization.
mlir/lib/Dialect/Tensor/IR/TensorOps.cpp | ||
---|---|---|
707 | Does this need to be moved out... seems like a legitimate canonicalization to me (similar to other cast folding canonicalizations). |
No worries, i can wait.
mlir/lib/Dialect/Tensor/IR/TensorOps.cpp | ||
---|---|---|
707 | Agreed, will move it back in a couple of hours. Thanks! |
The PR has too many LLVM commit, so it could be broken by other commits. Let me create a PR that only contain this commit..
EDIT: https://github.com/iree-org/iree/pull/11460 tests the patch in IREE
@hanchung you are looking at the wrong PR ( I posted the wrong one by mistake). Here is the right one https://github.com/iree-org/iree/pull/11454 . That has only one commit
Got this worked out in IREE (https://github.com/iree-org/iree/pull/11454/). Thanks for your patience. Looks good to me now!
You shouldnt need this pattern also actually (just FYI, no need to do it here). This happens as part of handling dims using InferRankedShapedTypeResultDims interface.