[Mlir-commits] [mlir] [mlir][memref] `memref.subview`: Verify result strides with rank reductions (PR #80158)
Jacques Pienaar
llvmlistbot at llvm.org
Thu Feb 1 16:21:53 PST 2024
================
@@ -2756,17 +2756,26 @@ static bool haveCompatibleOffsets(MemRefType t1, MemRefType t2) {
}
/// Return true if `t1` and `t2` have equal strides (both dynamic or of same
-/// static value).
-static bool haveCompatibleStrides(MemRefType t1, MemRefType t2) {
+/// static value). Dimensions of `t1` may be dropped in `t2`; these must be
+/// marked as dropped in `droppedDims`.
+static bool haveCompatibleStrides(MemRefType t1, MemRefType t2,
+ const llvm::SmallBitVector &droppedDims) {
+ assert(t1.getRank() == droppedDims.size() && "incorrect number of bits");
+ assert(t1.getRank() - t2.getRank() == droppedDims.count() &&
+ "incorrect number of dropped dims");
int64_t t1Offset, t2Offset;
SmallVector<int64_t> t1Strides, t2Strides;
auto res1 = getStridesAndOffset(t1, t1Strides, t1Offset);
auto res2 = getStridesAndOffset(t2, t2Strides, t2Offset);
if (failed(res1) || failed(res2))
return false;
- for (auto [s1, s2] : llvm::zip_equal(t1Strides, t2Strides))
- if (s1 != s2)
+ for (int64_t i = 0, j = 0; i < t1.getRank(); ++i) {
----------------
jpienaar wrote:
Nit: if rank doesn't change during iteration, hoist out (https://llvm.org/docs/CodingStandards.html#don-t-evaluate-end-every-time-through-a-loop)
https://github.com/llvm/llvm-project/pull/80158
More information about the Mlir-commits
mailing list