[Mlir-commits] [mlir] [MLIR][Linalg] Fix insert_slice fusion with rank reduction (PR #130961)

Andrzej WarzyƄski llvmlistbot at llvm.org
Wed Mar 26 02:24:11 PDT 2025


================
@@ -235,6 +237,39 @@ mlir::linalg::fuseProducerOfTensor(OpBuilder &b, OpOperand &consumerOpOperand) {
   return fuseProducerOfTensor(b, producerOpResult, consumerOpOperand);
 }
 
+/// Create tensor.collapse_shape to drop dimensions in `dropDims` in tensor
+/// `from`.
+static tensor::CollapseShapeOp
+collapseTo(OpBuilder &b, Location loc, Value from,
+           const llvm::SmallBitVector &dropDims) {
+  auto fromType = cast<ShapedType>(from.getType());
+  assert(fromType.getRank() == dropDims.size() &&
+         "dropDims dimension does not match from tensor rank");
+  // Computed reassociation map for the corresponding tensor.collapse_shape.
+  SmallVector<ReassociationIndices, 2> reassocIdxsVec;
----------------
banach-space wrote:

OK, thanks for the comments! Initially I got a bit confused -  in my "head" these are reassociation groups. As in, this is _a vector of reassociation groups_. I would rename this to make it clearer (perhaps there's a better name?)

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


More information about the Mlir-commits mailing list