[Mlir-commits] [mlir] 5d7e0a2 - [mlir] Add LinalgInterface method to clone with a given BlockAndValueMapping.

llvmlistbot at llvm.org llvmlistbot at llvm.org
Wed Mar 3 09:25:44 PST 2021


Author: MaheshRavishankar
Date: 2021-03-03T09:25:20-08:00
New Revision: 5d7e0a23c6f2051d4caf8f8c8821790c40b584be

URL: https://github.com/llvm/llvm-project/commit/5d7e0a23c6f2051d4caf8f8c8821790c40b584be
DIFF: https://github.com/llvm/llvm-project/commit/5d7e0a23c6f2051d4caf8f8c8821790c40b584be.diff

LOG: [mlir] Add LinalgInterface method to clone with a given BlockAndValueMapping.

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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.td
index dbb21a752cf1..84b1bcb8bad4 100644
--- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.td
+++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.td
@@ -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.


        


More information about the Mlir-commits mailing list