[Mlir-commits] [mlir] [MLIR] Bubble up tensor.extract_slice through tensor.collapse_shape (PR #131982)

Andrzej Warzyński llvmlistbot at llvm.org
Tue Mar 25 04:47:52 PDT 2025


================
@@ -428,6 +429,239 @@ struct BubbleUpExpandShapeThroughExtractSlice
   }
 };
 
+/// Converts `tensor.extract_slice(tensor.collapse_shape)` to
+///          `tensor.collapse_shape(tensor.extract_slice)`.
+///
+/// For this transformation to be possible - after bubbling up, the extraction
+/// of the contiguous slice must be representable as a single slice obtained via
+/// tensor.extract_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 within each reassociation group:
----------------
banach-space wrote:

Thank you for taking the time to write this very comprehensive explanation, this makes it super clear to me 🙏🏻 (and I was indeed incorrect)

I was just about to ask you to add this example as a test, but that's already done! :) 

https://github.com/llvm/llvm-project/pull/131982


More information about the Mlir-commits mailing list