[all-commits] [llvm/llvm-project] ce7cc7: [mlir][memref] `memref.subview`: Verify result str...

Matthias Springer via All-commits all-commits at lists.llvm.org
Wed Jan 31 02:09:50 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ce7cc723b9d51ad9c741bbaeecb5e008b2b81338
      https://github.com/llvm/llvm-project/commit/ce7cc723b9d51ad9c741bbaeecb5e008b2b81338
  Author: Matthias Springer <springerm at google.com>
  Date:   2024-01-31 (Wed, 31 Jan 2024)

  Changed paths:
    M mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
    M mlir/lib/Dialect/MemRef/Transforms/ExpandStridedMetadata.cpp
    M mlir/test/Dialect/GPU/decompose-memrefs.mlir
    M mlir/test/Dialect/MemRef/fold-memref-alias-ops.mlir
    M mlir/test/Dialect/MemRef/invalid.mlir
    M mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_rewrite_sort_coo.mlir

  Log Message:
  -----------
  [mlir][memref] `memref.subview`: Verify result strides

The `memref.subview` verifier currently checks result shape, element type, memory space and offset of the result type. However, the strides of the result type are currently not verified. This commit adds verification of result strides for non-rank reducing ops and fixes invalid IR in test cases.

Verification of result strides for ops with rank reductions is more complex (and there could be multiple possible result types). That is left for a separate commit.

Also refactor the implementation a bit:
* If `computeMemRefRankReductionMask` could not compute the dropped dimensions, there must be something wrong with the op. Return `FailureOr` instead of `std::optional`.
* `isRankReducedMemRefType` did much more than just checking whether the op has rank reductions or not. Inline the implementation into the verifier and add better comments.
* `produceSubViewErrorMsg` does not have to be templatized.
* Fix comment and add additional assert to `ExpandStridedMetadata.cpp`, to make sure that the memref.subview verifier is in sync with the memref.subview -> memref.reinterpret_cast lowering.

Note: This change is identical to #79865, but with a fixed comment and an additional assert in `ExpandStridedMetadata.cpp`. (I reverted #79865 in #80116, but the implementation was actually correct, just the comment in `ExpandStridedMetadata.cpp` was confusing.)




More information about the All-commits mailing list