[llvm] [mlir][bufferization] Generalize tensor slice rules to subset ops (PR #65619)
Martin Erhart via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 12 03:59:04 PDT 2023
================
@@ -1147,13 +1023,72 @@ struct SplatOpInterface
}
};
+namespace {
+/// Return "true" if `insertSliceOp` inserts into a subset that is equivalent
+/// to the subset defined by `candidate`. `equivalenceFn` is used to determine
+/// equivalence of tensors.
+template <typename OpTy>
+bool isSubsetEquivalentToInsertSliceLikeOp(
+ OpTy insertSliceOp, Value candidate,
+ function_ref<bool(Value, Value)> equivalenceFn) {
+ // Look for a matching tensor.extract_slice op.
+ auto extractSliceOp = candidate.getDefiningOp<tensor::ExtractSliceOp>();
+ if (!extractSliceOp)
+ return false;
+ if (!equivalenceFn(extractSliceOp.getSource(), insertSliceOp.getDest()))
+ return false;
+ if (!sameOffsetsSizesAndStrides(extractSliceOp, insertSliceOp,
+ isEqualConstantIntOrValue))
+ return false;
+ return true;
----------------
maerhart wrote:
```suggestion
return sameOffsetsSizesAndStrides(extractSliceOp, insertSliceOp,
isEqualConstantIntOrValue);
```
https://github.com/llvm/llvm-project/pull/65619
More information about the llvm-commits
mailing list