[Mlir-commits] [mlir] [mlir][fold-memref-alias-ops] Add support for folding memref.expand_shape involving dynamic dims (PR #89093)
Oleksandr Alex Zinenko
llvmlistbot at llvm.org
Thu Apr 25 03:45:51 PDT 2024
================
@@ -64,6 +64,34 @@ getLinearizedMemRefOffsetAndSize(OpBuilder &builder, Location loc, int srcBits,
// it means both the allocations and associated stores can be removed.
void eraseDeadAllocAndStores(RewriterBase &rewriter, Operation *parentOp);
+/// Given a set of sizes, return the suffix product.
+///
+/// When applied to slicing, this is the calculation needed to derive the
+/// strides (i.e. the number of linear indices to skip along the (k-1) most
+/// minor dimensions to get the next k-slice).
+///
+/// This is the basis to linearize an n-D offset confined to `[0 ... sizes]`.
+///
+/// Assuming `sizes` is `[s0, .. sn]`, return the vector<Value>
+/// `[s1 * ... * sn, s2 * ... * sn, ..., sn, 1]`.
+///
+/// It is the caller's responsibility to provide valid values which are expected
+/// to be constants with index type or results of dimension extraction ops
+/// (for ex. memref.dim op).
----------------
ftynse wrote:
This isn't actually a requirement of this function. It may be if it is called to insert IR inside an affine scope such as `affine.for` that imposes such requirements, but it would be the caller's responsibility to ensure that they construct valid IR in the end.
https://github.com/llvm/llvm-project/pull/89093
More information about the Mlir-commits
mailing list