[Mlir-commits] [mlir] [mlir] Introduce `trailingNDimsContiguous` for MemRefs (PR #78247)
Andrzej WarzyĆski
llvmlistbot at llvm.org
Tue Jan 23 12:41:21 PST 2024
================
@@ -967,3 +967,32 @@ bool mlir::isLastMemrefDimUnitStride(MemRefType type) {
auto successStrides = getStridesAndOffset(type, strides, offset);
return succeeded(successStrides) && (strides.empty() || strides.back() == 1);
}
+
+bool mlir::trailingNDimsContiguous(MemRefType type, int64_t n) {
+ if (!isLastMemrefDimUnitStride(type))
+ return false;
+
+ auto memrefShape = type.getShape().take_back(n);
+ int64_t offset;
+ SmallVector<int64_t> stridesFull;
+ if (!succeeded(getStridesAndOffset(type, stridesFull, offset)))
----------------
banach-space wrote:
I've just added a check that leverages [isIdentity](https://github.com/llvm/llvm-project/blob/e3172e841899779caf461cee97826940dca806e7/mlir/include/mlir/IR/BuiltinAttributeInterfaces.td#L475-L482).
> Is the memref layout being taken into account anywhere?
I thought that that's what `getStridesAndOffset` does (i.e. returns the layout as offsets and strides)? I am not 100% sure though, this is mostly just moving things around.
https://github.com/llvm/llvm-project/pull/78247
More information about the Mlir-commits
mailing list