[Mlir-commits] [mlir] [MLIR] Bubble up tensor.extract_slice through tensor.collapse_shape (PR #131982)
Andrzej WarzyĆski
llvmlistbot at llvm.org
Sun Mar 23 06:44:34 PDT 2025
================
@@ -428,6 +429,190 @@ struct BubbleUpExpandShapeThroughExtractSlice
}
};
+/// Converts `tensor.collapse_shape(tensor.extract_slice)` to
+/// `tensor.extract_slice(tensor.collapse_shape)`.
+///
+/// For this transformation to be possible, the slice must be representable as a
+/// contiguous slice within each reassociation group of the src.
+///
+/// In case the size and offset extracted are static then this is possible if
+/// the following conditions are met:
+/// Let T be a tensor of shape [A0, A1, ..., An], and let S = [S0, S1, ..., Sn]
+/// be the shape of a desired slice. A slice of shape S can be extracted as a
+/// contiguous block of memory if and only if there exists an index k in {0, 1,
----------------
banach-space wrote:
Note, in the context of tensor (which are abstract constructs) we can't really make references to "memory" (which is something physical).
https://github.com/llvm/llvm-project/pull/131982
More information about the Mlir-commits
mailing list