[Mlir-commits] [mlir] [mlir][tensor] Apply `InsertSliceOfTransferWriteOpFolder` only when `transfer_write` overwrites all elements of `insert_slice` (PR #108803)
Benjamin Maxwell
llvmlistbot at llvm.org
Mon Sep 23 07:41:24 PDT 2024
================
@@ -154,6 +166,25 @@ LogicalResult InsertSliceOfTransferWriteOpFolder::matchAndRewrite(
return success();
}
+bool InsertSliceOfTransferWriteOpFolder::doesTransferWriteCoverInsertSlice(
+ vector::TransferWriteOp writeOp, tensor::InsertSliceOp insertSliceOp,
+ MLIRContext *context) {
+ auto destType = cast<ShapedType>(writeOp.getOperand(0).getType());
+ auto insertSliceType = insertSliceOp.getSourceType();
+
+ if (destType.hasStaticShape() && insertSliceType.hasStaticShape()) {
+ for (int64_t d = 0, e = insertSliceType.getRank(); d < e; ++d) {
+ if (destType.getDimSize(d) != insertSliceType.getDimSize(d))
+ return false;
+ }
+ return true;
+ }
----------------
MacDue wrote:
I think this can be simplified a little. I think you only need to check the `writeOp` fully overwrites its destination tensor (do you don't need to pass `insertSliceOp` here).
https://github.com/llvm/llvm-project/pull/108803
More information about the Mlir-commits
mailing list