[Mlir-commits] [mlir] 6237cd7 - [mlir][Linalg] NFC - Add C++ builder to TileOp
Nicolas Vasilache
llvmlistbot at llvm.org
Sun Dec 18 05:51:22 PST 2022
Author: Nicolas Vasilache
Date: 2022-12-18T05:51:15-08:00
New Revision: 6237cd7785904e071f367eaef80df1848338614a
URL: https://github.com/llvm/llvm-project/commit/6237cd7785904e071f367eaef80df1848338614a
DIFF: https://github.com/llvm/llvm-project/commit/6237cd7785904e071f367eaef80df1848338614a.diff
LOG: [mlir][Linalg] NFC - Add C++ builder to TileOp
Added:
Modified:
mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td b/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
index 1cb321d76d030..cd330ec266240 100644
--- a/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
+++ b/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
@@ -968,6 +968,14 @@ def TileOp : Op<Transform_Dialect, "structured.tile",
DefaultValuedOptionalAttr<DenseI64ArrayAttr, "{}">:$interchange);
let results = (outs PDL_Operation:$tiled_linalg_op,
Variadic<PDL_Operation>:$loops);
+ let builders = [
+ OpBuilder<(ins "Value":$target,
+ "ArrayRef<int64_t>":$staticTileSizes,
+ CArg<"ArrayRef<int64_t>", "{}">:$interchange)>,
+ OpBuilder<(ins "Value":$target,
+ "ArrayRef<OpFoldResult>":$mixedTileSizes,
+ CArg<"ArrayRef<int64_t>", "{}">:$interchange)>
+ ];
let hasCustomAssemblyFormat = 1;
diff --git a/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp b/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
index 837beb7400c39..dd0f2e5f1d4f5 100644
--- a/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
+++ b/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
@@ -1281,6 +1281,36 @@ transform::TileReductionUsingForeachThreadOp::applyToOne(
//===----------------------------------------------------------------------===//
// TileOp
//===----------------------------------------------------------------------===//
+void transform::TileOp::build(OpBuilder &builder, OperationState &result,
+ Value target, ArrayRef<int64_t> staticTileSizes,
+ ArrayRef<int64_t> interchange) {
+ return build(builder, result,
+ /*target=*/target,
+ /*mixedTileSizes=*/
+ getAsOpFoldResult(builder.getI64ArrayAttr(staticTileSizes)),
+ interchange);
+}
+
+void transform::TileOp::build(OpBuilder &builder, OperationState &result,
+ Value target,
+ ArrayRef<OpFoldResult> mixedTileSizes,
+ ArrayRef<int64_t> interchange) {
+ SmallVector<int64_t> staticTileSizes;
+ SmallVector<Value> dynamicTileSizes;
+ dispatchIndexOpFoldResults(mixedTileSizes, dynamicTileSizes, staticTileSizes);
+ // Call the default builder which sets up the proper operands segment sizes
+ // attributes for multiple variadic operands. In the absence of this, horrible
+ // bugs ensue.
+ MLIRContext *ctx = builder.getContext();
+ auto operationType = pdl::OperationType::get(ctx);
+ auto staticTileSizesAttr = builder.getDenseI64ArrayAttr(staticTileSizes);
+ build(builder, result,
+ /*resultTypes=*/TypeRange{operationType, operationType},
+ /*target=*/target,
+ /*dynamic_sizes=*/dynamicTileSizes,
+ /*static_sizes=*/staticTileSizesAttr,
+ /*interchange=*/builder.getDenseI64ArrayAttr(interchange));
+}
DiagnosedSilenceableFailure
transform::TileOp::apply(TransformResults &transformResults,
More information about the Mlir-commits
mailing list