-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Revert "[mlir] Fix TileUsingForOp
attr-dict printing/parsing, cleanup assembly format"
#73178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This reverts commit 0401668.
@llvm/pr-subscribers-mlir-linalg @llvm/pr-subscribers-mlir Author: Felix Schneider (ubfx) ChangesReverts llvm/llvm-project#72745 Full diff: https://github.com/llvm/llvm-project/pull/73178.diff 3 Files Affected:
diff --git a/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td b/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
index c8f0806e27a6264..f1c3d717f1fa951 100644
--- a/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
+++ b/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
@@ -1819,7 +1819,7 @@ def TileUsingForOp : Op<Transform_Dialect, "structured.tile_using_for",
let arguments = (ins TransformHandleTypeInterface:$target,
Variadic<TransformParamTypeOrAnyHandle>:$dynamic_sizes,
DefaultValuedOptionalAttr<DenseI64ArrayAttr, "{}">:$static_sizes,
- DefaultValuedOptionalAttr<I64ArrayAttr, "{}">:$interchange,
+ DefaultValuedOptionalAttr<DenseI64ArrayAttr, "{}">:$interchange,
DefaultValuedOptionalAttr<DenseBoolArrayAttr, "{}">:$scalable_sizes);
let results = (outs TransformHandleTypeInterface:$tiled_linalg_op,
Variadic<TransformHandleTypeInterface>:$loops);
diff --git a/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp b/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
index 73de3f22d896f0a..de4965f937162ea 100644
--- a/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
+++ b/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
@@ -2477,7 +2477,7 @@ void transform::TileUsingForOp::build(
/*target=*/target,
/*dynamic_sizes=*/dynamicTileSizes,
/*static_sizes=*/staticTileSizesAttr,
- /*interchange=*/builder.getI64ArrayAttr(interchange),
+ /*interchange=*/builder.getDenseI64ArrayAttr(interchange),
/*scalable_sizes=*/expandedScalableSizes);
}
@@ -2611,8 +2611,7 @@ transform::TileUsingForOp::apply(transform::TransformRewriter &rewriter,
});
}
- tilingOptions.setInterchange(
- extractFromIntegerArrayAttr<int64_t>(getInterchange()));
+ tilingOptions.setInterchange(getInterchange());
FailureOr<scf::SCFTilingResult> maybeTilingResult =
tileUsingSCFForOp(rewriter, tilingInterface, tilingOptions);
if (failed(maybeTilingResult))
@@ -2649,6 +2648,33 @@ SmallVector<OpFoldResult> transform::TileUsingForOp::getMixedSizes() {
return results;
}
+// We want to parse `DenseI64ArrayAttr` using the short form without the
+// `array` prefix to be consistent in the IR with `parseDynamicIndexList`.
+ParseResult parseOptionalInterchange(OpAsmParser &parser,
+ OperationState &result) {
+ if (succeeded(parser.parseOptionalLBrace())) {
+ if (failed(parser.parseKeyword("interchange")))
+ return parser.emitError(parser.getNameLoc()) << "expect `interchange`";
+ if (failed(parser.parseEqual()))
+ return parser.emitError(parser.getNameLoc()) << "expect `=`";
+ result.addAttribute("interchange",
+ DenseI64ArrayAttr::parse(parser, Type{}));
+ if (failed(parser.parseRBrace()))
+ return parser.emitError(parser.getNameLoc()) << "expect `}`";
+ }
+ return success();
+}
+
+void printOptionalInterchange(OpAsmPrinter &p,
+ ArrayRef<int64_t> interchangeVals) {
+ if (!interchangeVals.empty()) {
+ p << " {interchange = [";
+ llvm::interleaveComma(interchangeVals, p,
+ [&](int64_t integer) { p << integer; });
+ p << "]}";
+ }
+}
+
ParseResult transform::TileUsingForOp::parse(OpAsmParser &parser,
OperationState &result) {
OpAsmParser::UnresolvedOperand target;
@@ -2660,7 +2686,7 @@ ParseResult transform::TileUsingForOp::parse(OpAsmParser &parser,
if (parser.parseOperand(target) || parser.getCurrentLocation(&operandLoc) ||
parseDynamicIndexList(parser, dynamicSizes, staticSizes, scalableVals) ||
- parser.parseOptionalAttrDict(result.attributes) ||
+ parseOptionalInterchange(parser, result) ||
parser.parseColonType(functionalType))
return ParseResult::failure();
@@ -2694,10 +2720,7 @@ void TileUsingForOp::print(OpAsmPrinter &p) {
printDynamicIndexList(p, getOperation(), getDynamicSizes(), getStaticSizes(),
/*valueTypes=*/{}, getScalableSizesAttr(),
OpAsmParser::Delimiter::Square);
- p.printOptionalAttrDict(
- (*this)->getAttrs(),
- /*elidedAttrs=*/{getScalableSizesAttrName(getOperation()->getName()),
- getStaticSizesAttrName(getOperation()->getName())});
+ printOptionalInterchange(p, getInterchange());
p << " : ";
p.printFunctionalType(getOperands().getTypes(), getResults().getTypes());
}
diff --git a/mlir/test/Dialect/Linalg/transform-ops.mlir b/mlir/test/Dialect/Linalg/transform-ops.mlir
index 4d7c514dcca62d5..e9f044be5b4ed22 100644
--- a/mlir/test/Dialect/Linalg/transform-ops.mlir
+++ b/mlir/test/Dialect/Linalg/transform-ops.mlir
@@ -6,14 +6,6 @@ transform.sequence failures(propagate) {
%0, %1:2 = transform.structured.tile_using_for %arg0 [2, 0, 3] : (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op)
}
-// check that the Attributes of `tile_using_for` are preserved through printing
-// and parsing.
-transform.sequence failures(propagate) {
-^bb1(%arg0: !transform.any_op):
- // CHECK %{{.*}}, %{{.*}}:2 = transform.structured.tile %arg0 [2, 0, 3] {interchange = [2, 1], test_attr1 = 1 : i64, test_attr2}
- %0, %1:2 = transform.structured.tile_using_for %arg0 [2, 0, 3] {test_attr1 = 1 : i64, interchange = [2, 1], test_attr2}: (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op)
-}
-
transform.sequence failures(propagate) {
^bb1(%arg0: !transform.any_op):
%0:2 = transform.structured.split %arg0 after 42 { dimension = 0 } : !transform.any_op
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Reverts #72745 as it is causing test failures on mlir-nvidia in
mlir/test/python/dialects/transform_structured_ext.py
.