-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[MLIR][TableGen] Use arg index in InferredResultType constructor. #122717
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
Conversation
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
@llvm/pr-subscribers-mlir Author: Philipp Schilk (schilkp) ChangesTrying to constrain two results to be of the same type using Example:
This is because there was a small bug when constructing the [1] llvm-project/mlir/lib/TableGen/Operator.cpp Line 526 in 99612a3
Full diff: https://github.com/llvm/llvm-project/pull/122717.diff 2 Files Affected:
diff --git a/mlir/lib/TableGen/Operator.cpp b/mlir/lib/TableGen/Operator.cpp
index c360c61afd27bd..20a43ef15d09eb 100644
--- a/mlir/lib/TableGen/Operator.cpp
+++ b/mlir/lib/TableGen/Operator.cpp
@@ -503,8 +503,8 @@ void Operator::populateTypeInferenceInfo(
for (int otherResultIndex : resultIndices) {
if (resultIndex == otherResultIndex)
continue;
- inference[resultIndex].sources.emplace_back(otherResultIndex,
- "$_self");
+ inference[resultIndex].sources.emplace_back(
+ InferredResultType::unmapResultIndex(otherResultIndex), "$_self");
}
}
}
diff --git a/mlir/test/mlir-tblgen/op-result.td b/mlir/test/mlir-tblgen/op-result.td
index 51f8b0671a328d..f668d9a5a6644a 100644
--- a/mlir/test/mlir-tblgen/op-result.td
+++ b/mlir/test/mlir-tblgen/op-result.td
@@ -180,6 +180,27 @@ def OpL4 : NS_Op<"two_inference_edges", [
// CHECK: inferredReturnTypes[1] = odsInferredType1
// CHECK: inferredReturnTypes[2] = odsInferredType2
+def OpL5 : NS_Op<"op_with_same_but_unconstraint_results",
+ [AllTypesMatch<["result_a", "result_b"]>]> {
+ let results = (outs AnyType:$result_a, AnyType:$result_b);
+}
+
+// CHECK-NOT: LogicalResult OpL5::inferReturnTypes
+
+def OpL6 : NS_Op<"op_with_same_and_constraint_results",
+ [AllTypesMatch<["result_a", "result_b", "result_c"]>]> {
+ let results = (outs AnyType:$result_a, AnyType:$result_b, I32:$result_c);
+}
+
+// CHECK-LABEL: LogicalResult OpL6::inferReturnTypes
+// CHECK-NOT: }
+// CHECK: odsInferredType0 = odsBuilder.getIntegerType(32);
+// CHECK: odsInferredType1 = odsBuilder.getIntegerType(32);
+// CHECK: odsInferredType2 = odsBuilder.getIntegerType(32);
+// CHECK: inferredReturnTypes[0] = odsInferredType0;
+// CHECK: inferredReturnTypes[1] = odsInferredType1;
+// CHECK: inferredReturnTypes[2] = odsInferredType2;
+
def OpM : NS_Op<"mix_diff_size_variadic_and_normal_results_op", [AttrSizedResultSegments]> {
let results = (outs Variadic<AnyTensor>:$output1, AnyTensor:$output2, Optional<AnyTensor>:$output3);
}
|
`InferredResultType` construct expects an "result and arg"-style index (with results negative and args positive), and not a results index (results nonegative).
2b55f82
to
d90100b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
@schilkp Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR. Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues. How to do this, and the rest of the post-merge process, is covered in detail here. If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! |
…vm#122717) Trying to constrain two results to be of the same type using `AllTypesMatch` would cause `mlir-tablgen` to crash on this assertion[1]. Example: ```tblgen def OpL5 : NS_Op<"op_with_same_but_unconstraint_results", [AllTypesMatch<["result_a", "result_b"]>]> { let results = (outs AnyType:$result_a, AnyType:$result_b); } ``` This is because there was a small bug when constructing the `inferences` graph from these constraints: The sources should be specified by the combined arg/result index (in other words, with results negative) not with the result index. [1] https://github.com/llvm/llvm-project/blob/99612a3a18e0c40aac9c52b68e67b106f97ed4fa/mlir/lib/TableGen/Operator.cpp#L526
Trying to constrain two results to be of the same type using
AllTypesMatch
would causemlir-tablgen
to crash on this assertion[1].Example:
This is because there was a small bug when constructing the
inferences
graph from these constraints: The sources should be specified by the combined arg/result index (in other words, with results negative) not with the result index.[1]
llvm-project/mlir/lib/TableGen/Operator.cpp
Line 526 in 99612a3