-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[mlir][arith] Add printing integration tests #98184
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
base: main
Are you sure you want to change the base?
Conversation
@llvm/pr-subscribers-mlir @llvm/pr-subscribers-mlir-arith Author: Jacob Yu (pingshiyu) ChangesPrinting operations regression tests, from the original larger PR that has been broken down: #92272 Full diff: https://github.com/llvm/llvm-project/pull/98184.diff 1 Files Affected:
diff --git a/mlir/test/Integration/Dialect/Arith/CPU/print.mlir b/mlir/test/Integration/Dialect/Arith/CPU/print.mlir
new file mode 100644
index 0000000000000..d322c23952bab
--- /dev/null
+++ b/mlir/test/Integration/Dialect/Arith/CPU/print.mlir
@@ -0,0 +1,47 @@
+// RUN: mlir-opt %s --convert-scf-to-cf --convert-cf-to-llvm --convert-vector-to-llvm \
+// RUN: --convert-func-to-llvm --convert-arith-to-llvm | \
+// RUN: mlir-cpu-runner -e entry -entry-point-result=void \
+// RUN: --shared-libs=%mlir_c_runner_utils | \
+// RUN: FileCheck %s --match-full-lines
+
+func.func @i1() {
+ // printing i1 values
+ // print(0 : i1) = '0'; print(1 : i1) = '1'; print(-1 : i1) = '1'
+ // CHECK: 0
+ // CHECK-NEXT: 1
+ // CHECK-NEXT: 1
+ %false = arith.constant false
+ %true = arith.constant 1 : i1
+ %true_as_n1 = arith.constant -1 : i1
+ vector.print %false : i1
+ vector.print %true : i1
+ vector.print %true_as_n1 : i1
+ return
+}
+
+func.func @index() {
+ // printing index values
+ // print(0 : index) = '0'; print(1 : index) = '1'; print(-1 : index) = '2^w - 1'
+ // index constants are printed as unsigned
+ // vector.print(arith.constant(x)) ~= toUnsignedRepr x
+ // CHECK-NEXT: 0
+ // CHECK-NEXT: 1
+ // CHECK-NEXT: 18446744073709551615
+ // CHECK-NEXT: 63
+ %c0 = arith.constant 0 : index
+ %c1 = arith.constant 1 : index
+ %cn1 = arith.constant -1 : index
+ %c63 = arith.constant 63 : index
+
+ vector.print %c0 : index
+ vector.print %c1 : index
+ vector.print %cn1 : index
+ vector.print %c63 : index
+ return
+}
+
+func.func @entry() {
+ func.call @i1() : () -> ()
+ func.call @index() : () -> ()
+ return
+}
|
%false = arith.constant false | ||
%true = arith.constant 1 : i1 |
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.
Could we use either 0 / 1 or false / true for consistency here?
func.func @index() { | ||
// printing index values | ||
// print(0 : index) = '0'; print(1 : index) = '1'; print(-1 : index) = '2^w - 1' | ||
// index constants are printed as unsigned | ||
// vector.print(arith.constant(x)) ~= toUnsignedRepr x | ||
// CHECK-NEXT: 0 | ||
// CHECK-NEXT: 1 | ||
// CHECK-NEXT: 18446744073709551615 | ||
// CHECK-NEXT: 63 | ||
%c0 = arith.constant 0 : index | ||
%c1 = arith.constant 1 : index | ||
%cn1 = arith.constant -1 : index | ||
%c63 = arith.constant 63 : index | ||
|
||
vector.print %c0 : index | ||
vector.print %c1 : index | ||
vector.print %cn1 : index | ||
vector.print %c63 : index | ||
return | ||
} |
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.
Could we specify the index type in the mlir-opt pipeline above? I'm worried this can be printed as u64 or u32 depending on the host
Thanks for adding tests, we surely have holes here and there and not enough people closing them... :)
Please provide a standalone description, we don't need to refer another PR here and instead I'd rather see here a clear "why" these tests are added. Thanks! |
%true_as_n1 = arith.constant -1 : i1 | ||
vector.print %false : i1 | ||
vector.print %true : i1 | ||
vector.print %true_as_n1 : i1 |
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.
From what I can tell, this is not testing anything about arith is it? Seems like this is all about testing "vector.print" in itself, or even just the testing runtime we have.
Can you try to make the file location more relevant?
Can we also consolidate all the testing for the runtime in a single execution? (each new lit test isn't free: it'll fork/exec a compiler process, and then execute the result here).
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.
Can we also consolidate all the testing for the runtime in a single execution? (each new lit test isn't free: it'll fork/exec a compiler process, and then execute the result here).
I advocated for keeping them in separate files - to make sure the tests are minimal and to make it easier to identify what's being tested. That has made reviewing much easier, but I didn't really think about the runtime cost. Consolidation makes sense, but l'd wait until all PR's from #100121 are complete. Is that OK?
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.
From what I can tell, this is duplicating https://github.com/llvm/llvm-project/blob/main/mlir/test/Integration/Dialect/Vector/CPU/print-int.mlir, no?
Printing operations regression tests, from the original larger PR that has been broken down: #92272