Skip to content

Commit 5d7e0a2

Browse files
author
MaheshRavishankar
committed
[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
1 parent c8cf27e commit 5d7e0a2

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,6 +1112,27 @@ def LinalgStructuredInterface : OpInterface<"LinalgOp"> {
11121112
return b.createOperation(state);
11131113
}]
11141114
>,
1115+
InterfaceMethod<
1116+
/*desc=*/[{
1117+
Clone the current operation with the given location, operands
1118+
and BlockAndValueMapping. This is used to abstract away the
1119+
optional underlying region creation. This does not change the
1120+
balance between input, output_buffer and init_tensors
1121+
operands.
1122+
}],
1123+
/*retTy=*/"Operation *",
1124+
/*methodName=*/"cloneWithMapper",
1125+
(ins "OpBuilder &":$b, "Location":$loc, "TypeRange":$resultTypes,
1126+
"ValueRange":$operands, "BlockAndValueMapping &":$bvm),
1127+
[{
1128+
OperationState state(
1129+
loc, ConcreteOp::getOperationName(), operands, resultTypes,
1130+
$_op->getAttrs());
1131+
for (Region &r : $_op->getRegions())
1132+
r.cloneInto(state.addRegion(), bvm);
1133+
return b.createOperation(state);
1134+
}]
1135+
>,
11151136
StaticInterfaceMethod<
11161137
/*desc=*/[{
11171138
Returns the region builder for constructing the body for linalg.generic.

0 commit comments

Comments
 (0)