[PATCH] D133166: [mlir][MemRef] Canonicalize extract_strided_metadata(subview)

Quentin Colombet via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 6 10:03:11 PDT 2022


qcolombet added a comment.

> the patterns we are talking about here should probably not be canonicalization patterns but rather patterns that we can apply with a specific new pass to fold away the subview ops in the presence of memref.extract_strided_metadata.
> See https://reviews.llvm.org/D128986 for a PR that does these foldings with load/store operations.

Thanks for the pointer!

I'll move the logic in that pass while using the affine ops and then we can decide if we want a new pass or not.



================
Comment at: mlir/test/Dialect/MemRef/canonicalize.mlir:910
+//
+//       CHECK: return %[[BASE]], %[[FINAL_OFFSET]], %[[C6]], %[[C3]], %[[STRIDES]]#1, %[[STRIDES]]#2
+func.func @extract_strided_metadata_of_rank_reduced_subview(%base: memref<8x16x4xf32>) -> (memref<f32>, index, index, index, index, index) {
----------------
nicolasvasilache wrote:
> In this example and below I believe some foldings and tests are missing.
> The strides of `%ARG` are known, they are `[64, 4, 1]`, so the return should be `%[[C4]]`, `%[[C1]]`.
> 
> It would be nice to also have some mixed tests where the function argument type has e.g. `strides<?x2>` etc.
> 
> You could have 1 fully dynamic test that spells out all the IR (adds, muls etc) and a few other tests that are just 1-line cheks and look that the return have the right constant in the proper place.
Good point!
I was hoping the `getStrides` would do the right thing, but it doesn't.
Looks like we need to introduce another getter to get the attribute of the input memref and not the produced values in that case. (More precisely, I think we'll want a getter that returns a `OpFoldResult`.)

Looking.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D133166/new/

https://reviews.llvm.org/D133166



More information about the llvm-commits mailing list