[Mlir-commits] [mlir] [MLIR][SCF] Add an API to fuse consumer to a producer within scf loop (PR #88712)

Abhishek Varma llvmlistbot at llvm.org
Thu Apr 18 04:44:24 PDT 2024


================
@@ -1100,6 +1101,428 @@ mlir::scf::tileConsumerAndFuseProducersUsingSCF(
                                    replacements};
 }
 
+//===----------------------------------------------------------------------===//
+// tileAndFuseConsumerUsingSCF implementation.
+//===----------------------------------------------------------------------===//
+
+/// In the following function `source` is the source operand of
+/// tensor.insert_slice op. We traverse through the use-def chain of the same
+/// through the containing scf.for to fetch the first untiled consumer.
+static std::tuple<Operation *, std::optional<OpOperand *>>
+getUntiledConsumerFromSliceDestSCFFor(OpOperand &source,
+                                      unsigned &operandNumber) {
----------------
Abhishek-Varma wrote:

It's used within [replaceInsertSliceWithTiledConsumer](https://github.com/llvm/llvm-project/blob/f2da6702a0967fbd667fff6fa94ac4ba681a0cc2/mlir/lib/Dialect/Tensor/Transforms/SwapExtractSliceWithProducerPatterns.cpp#L59) - so sending in only that operand which the consumer consumes from the scf loop.

I have also added a `resultNumber` - this helps us to deal with multiple value yielding scf loop.

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


More information about the Mlir-commits mailing list