[Mlir-commits] [mlir] [MLIR][SCF] Add an API to fuse consumer to a producer within scf loop (PR #88712)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Wed Apr 17 21:50:30 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) {
+ // Step 1. Fetch the corresponding output
+ // TODO(avarma): Make it generic for multiple values yielding scf.for.
+ unsigned yieldOperandNumber = source.getOperandNumber();
----------------
MaheshRavishankar wrote:
I dont know how this works based on the comment above. If the `source` is the source of the `tensor.insert_slice` the operand number is always 0, which is not same as the yield number. I think you first need to walk the uses of the result of the `insert_slice` to get to the `scf.yeild` (you can assert single use of the result of the insert_slice for now) and that gives you the yieldOperandNumber.
https://github.com/llvm/llvm-project/pull/88712
More information about the Mlir-commits
mailing list