[Mlir-commits] [mlir] [mlir][vector] Drop innermost unit dims on transfer_write. (PR #78554)
Han-Chung Wang
llvmlistbot at llvm.org
Thu Jan 18 11:55:04 PST 2024
================
@@ -1152,8 +1152,71 @@ struct FoldI1Select : public OpRewritePattern<arith::SelectOp> {
}
};
-// Drop inner most contiguous unit dimensions from transfer_read operand.
-class DropInnerMostUnitDims : public OpRewritePattern<vector::TransferReadOp> {
+/// Returns the number of dims can be folded away from transfer ops. It returns
+/// a failure if strides and offsets can not be resolved.
+static FailureOr<size_t>
+getTransferFoldableInnerUnitDims(MemRefType srcType, VectorType vectorType) {
+ SmallVector<int64_t> srcStrides;
+ int64_t srcOffset;
+ if (failed(getStridesAndOffset(srcType, srcStrides, srcOffset)))
+ return failure();
+
+ // According to vector.transfer_read/write semantics, the vector can be a
+ // slice. It pads the indices with `1` starting from beginning. Thus, we have
+ // to offset the check index with `rankDiff` in `srcStrides` and source dim
+ // sizes.
----------------
hanhanW wrote:
I see, I think I wrote it in a wrong way. The logic was added by others three years ago. I fixed a bug and added a comment about it few months ago. I was wrong on the comment; we still need the logic. I will update the comment properly. Many thanks on this!
https://github.com/llvm/llvm-project/pull/78554
More information about the Mlir-commits
mailing list