This commit adds utility functions to perform general merging of
OffsetSizeAndStrideOpInterface by supporting producer rank
reducing and non-unit strides.
With it we can extend MergeConsecutiveExtractSlice to support
more cases.
Differential D134294
[mlir][tensor] Support more cases in MergeConsecutiveExtractSlice antiagainst on Sep 20 2022, 11:08 AM. Authored by
Details This commit adds utility functions to perform general merging of With it we can extend MergeConsecutiveExtractSlice to support
Diff Detail
Event TimelineComment Actions Seems like this is failing when built with GCC as host compiler: https://buildkite.com/mlir/mlir-core/builds/25622#01835d94-e233-483d-a001-8a9dadc530b7 Comment Actions Seems like the utility function mergeOffsetsSizesAndStrides should be added to ViewLikeInterface or Dialect/Utils because it has greater scope. The primary use that comes to mind is that the memref "fold alias ops" (used to be "fold subviews") essential does the same thing (SubView and ExtractSlice are both implement the OffsetSizeAndStrideOpInterface). Therefore, it seems like an opportunity for code de-duplication. Edit: I tried doing this in https://reviews.llvm.org/D134393 and run into the issue with Interface/ViewLikeInterface depending on Dialect/Utils and use of Affine ops. So the only common place it could go to be used by Memref and Tensor dialects is in affine dialect utils.
Comment Actions Thanks @mehdi_amini for the revert! I'll address it tomorrow. Thanks @christopherbate for the suggestion! Yeah I didn't put in the ViewLikeInterface impl cpp because of the affine op dependency. Didn't know about the makeComposedFoldedAffineApply; that's pretty nice! Let me update accordingly tomorrow. Comment Actions Relanded https://reviews.llvm.org/rGbd81524e7f52c38ad0bc689934343a476e545265 and uploaded https://reviews.llvm.org/D134487 to move to a more common place to be shared with memref too. |
All three of these helper functions seem superfluous because the the makeComposedFoldedAffineApply does the optimization in getAffineExpr and the expressions aren't complicated enough to require the add and mul helpers. I tested the below code: