[Mlir-commits] [mlir] [mlir][Linalg]: Optimize linalg generic in transform::PromoteOp to avoid unnecessary copies (PR #68555)

lorenzo chelini llvmlistbot at llvm.org
Wed Oct 11 03:11:41 PDT 2023


================
@@ -174,6 +177,11 @@ 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) ||
----------------
chelini wrote:

`payloadUsesValueFromOperand` is an interface method of `LinalgStructuredInterface`, and the copy operation implements `LinalgStructuredInterface` too. Looking at `LinalgNamedStructuredOps.yamlgen.td` (you find it in the build dir) CopyOp "derives" from `LinalgStructuredBase_Op`, which implements `LinalgStructuredInterface`, thus `payloadUsesValueFromOperand` is well defined also for `CopyOp` too. 

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


More information about the Mlir-commits mailing list