[Mlir-commits] [mlir] 9b1f162 - [mlir][Linalg] NFC - Add builder for TileToScfForOp
Nicolas Vasilache
llvmlistbot at llvm.org
Tue Apr 18 05:01:33 PDT 2023
Author: Nicolas Vasilache
Date: 2023-04-18T05:00:52-07:00
New Revision: 9b1f1622449a1580c4fbae089a4e087efd835da4
URL: https://github.com/llvm/llvm-project/commit/9b1f1622449a1580c4fbae089a4e087efd835da4
DIFF: https://github.com/llvm/llvm-project/commit/9b1f1622449a1580c4fbae089a4e087efd835da4.diff
LOG: [mlir][Linalg] NFC - Add builder for TileToScfForOp
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 6af12109c92ab..56fd2e0541975 100644
--- a/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
+++ b/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
@@ -1709,6 +1709,12 @@ def TileToScfForOp : Op<Transform_Dialect, "structured.tile_to_scf_for",
DefaultValuedOptionalAttr<DenseI64ArrayAttr, "{}">:$interchange);
let results = (outs PDL_Operation:$tiled_linalg_op,
Variadic<PDL_Operation>:$loops);
+
+ let builders = [
+ 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 23c4020200522..8c31e4184b786 100644
--- a/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
+++ b/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
@@ -2821,6 +2821,30 @@ LogicalResult TileToForallOp::verify() {
// TileToScfForOp
//===----------------------------------------------------------------------===//
+void transform::TileToScfForOp::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.
+ auto staticTileSizesAttr = builder.getDenseI64ArrayAttr(staticTileSizes);
+ int64_t numExpectedLoops =
+ staticTileSizes.size() - llvm::count(staticTileSizes, 0);
+ SmallVector<Type> resultTypes;
+ resultTypes.reserve(numExpectedLoops);
+ build(builder, result,
+ /*tiled_linalg_op=*/target.getType(),
+ /*loops=*/resultTypes,
+ /*target=*/target,
+ /*dynamic_sizes=*/dynamicTileSizes,
+ /*static_sizes=*/staticTileSizesAttr,
+ /*interchange=*/builder.getDenseI64ArrayAttr(interchange));
+}
+
DiagnosedSilenceableFailure
transform::TileToScfForOp::apply(TransformResults &transformResults,
TransformState &state) {
More information about the Mlir-commits
mailing list