[mlir] Add LinalgInterface method to clone with a given BlockAndValueMapping.
authorMaheshRavishankar <ravishankarm@google.com>
Wed, 3 Mar 2021 17:24:29 +0000 (09:24 -0800)
committerMaheshRavishankar <ravishankarm@google.com>
Wed, 3 Mar 2021 17:25:20 +0000 (09:25 -0800)
Since Linalg operations have regions by default which are not isolated
from above, add an another method to the interface that will take a
BlockAndValueMapping to remap the values within the region as well.

Differential Revision: https://reviews.llvm.org/D97709

mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.td

index dbb21a7..84b1bcb 100644 (file)
@@ -1112,6 +1112,27 @@ def LinalgStructuredInterface : OpInterface<"LinalgOp"> {
         return b.createOperation(state);
       }]
     >,
+    InterfaceMethod<
+      /*desc=*/[{
+        Clone the current operation with the given location, operands
+        and BlockAndValueMapping. This is used to abstract away the
+        optional underlying region creation. This does not change the
+        balance between input, output_buffer and init_tensors
+        operands.
+      }],
+      /*retTy=*/"Operation *",
+      /*methodName=*/"cloneWithMapper",
+      (ins "OpBuilder &":$b, "Location":$loc, "TypeRange":$resultTypes,
+           "ValueRange":$operands, "BlockAndValueMapping &":$bvm),
+      [{
+        OperationState state(
+          loc, ConcreteOp::getOperationName(), operands, resultTypes,
+          $_op->getAttrs());
+        for (Region &r : $_op->getRegions())
+          r.cloneInto(state.addRegion(), bvm);
+        return b.createOperation(state);
+      }]
+    >,
     StaticInterfaceMethod<
       /*desc=*/[{
         Returns the region builder for constructing the body for linalg.generic.