[Mlir-commits] [mlir] [mlir][Linalg]: Optimize any structured linalg operation in transform::PromoteOp to avoid unnecessary copies (PR #69876)

Nicolas Vasilache llvmlistbot at llvm.org
Fri Oct 27 07:27:52 PDT 2023


================
@@ -177,10 +177,8 @@ LinalgOpInstancePromotionOptions::LinalgOpInstancePromotionOptions(
     Operation *op = opOperand.get().getDefiningOp();
     if (auto sv = dyn_cast_or_null<memref::SubViewOp>(op)) {
       subViews[operandNumber] = sv;
-      // In case of linalg generic, copy in only if subview is used in linalg
-      // payload.
-      if (!isa<linalg::GenericOp>(linalgOp) ||
-          linalgOp.payloadUsesValueFromOperand(&opOperand))
+      // Copy in only if subview is being used by the linalg operation.
+      if (linalgOp.isDpsInput(&opOperand) || !linalgOp.isInitTensor(&opOperand))
----------------
nicolasvasilache wrote:

I think `isDpsInput` does not check `payloadUsesValueFromOperand` AFAIR.
To achieve what you seem to reach for here, you prob want a condition that does both `payloadUsesValueFromOperand` for inputs and `!linalgOp.isInitTensor(&opOperand)` for other operands.

In any case you should also have a test where one of the inputs is ignored I think.


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


More information about the Mlir-commits mailing list