[Mlir-commits] [mlir] [mlir][scf] Extend consumer fuse to nested loop structure (PR #94190)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Fri Sep 6 00:51:43 PDT 2024


================
@@ -1464,12 +1464,36 @@ checkAssumptionForFusingConsumer(tensor::InsertSliceOp candidateSliceOp) {
 /// failure otherwise.
 static FailureOr<OpOperand *> getConsumerFromUses(Value val,
                                                   Block *containingOpBlock) {
-  // Step 1. Check that the value has exactly one use.
-  if (!llvm::hasSingleElement(val.getUses()))
-    return failure();
+  // Step 1. Check that the value has exactly one use excluding `insertSliceOp`
+  // or `ParallelInsertSliceOp`.
+  OpOperand *operand = nullptr;
----------------
Yun-Fly wrote:

I am afraid not. Please note that `%2` has totally three uses:
1. the `candidateSliceOp` is actually `tensor.parallel_insert_slice %2`,  
2. the `%4 = insert_slice %2` used by `extract_slice` is a cloned candidate. 
3. `%6 = tiledConsumer ins(%2)` is tiled consumer.

As the result, even if we erase cloned slice, there still remains two uses of `%2`. As for `tensor.parallel_insert_slice %2`, it is hard to be erased unless we reconstruct `scf.forall`.

> so that we dont have to make this more complicated?

Personally, I think current solution is not too complicated..

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


More information about the Mlir-commits mailing list