-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dialects: (builtin) mimic mlir floating point precision for printing …
…and parsing (#3607) I'm running into some precision issues when printing and parsing floats after they have been packed/unpacked. This PR tries to resolve the issues with printing and parsing, trying to mimic MLIR behaviour as much as possible.
- Loading branch information
1 parent
414bcb0
commit 7e38685
Showing
14 changed files
with
117 additions
and
56 deletions.
There are no files selected for viewing
This file contains 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 file contains 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 file contains 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
32 changes: 32 additions & 0 deletions
32
tests/filecheck/mlir-conversion/with-mlir/dialects/builtin/builtin_fp_types.mlir
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// RUN: mlir-opt %s | filecheck %s | ||
// RUN: xdsl-opt %s | filecheck %s | ||
|
||
// CHECK: module { | ||
|
||
// f16 is always representable with scientific format | ||
arith.constant 1.1 : f16 | ||
// CHECK-NEXT: {{%.*}} = arith.constant 1.099610e+00 : f16 | ||
|
||
// f32 is represented by scientific format if it is precise enough | ||
arith.constant 3.1415 : f32 | ||
// CHECK-NEXT: {{%.*}} = arith.constant 3.141500e+00 : f32 | ||
|
||
// else, f32 is printed with 9 significant digits | ||
arith.constant 3.141592 : f32 | ||
// CHECK-NEXT: {{%.*}} = arith.constant 3.14159203 : f32 | ||
|
||
// if the decimal separator is within these 9 siginficant non-zero digits, fine | ||
arith.constant 2.997925e+05 : f32 | ||
// CHECK-NEXT: {{%.*}} = arith.constant 299792.5 : f32 | ||
|
||
// else, print hex format | ||
arith.constant 2.997925e+06 : f32 | ||
// CHECK-NEXT: {{%.*}} = arith.constant 0x4A36FA94 : f32 | ||
|
||
// f64 is represented by scientific format if it is precise enough | ||
arith.constant 3.1415 : f64 | ||
// CHECK-NEXT: {{%.*}} = arith.constant 3.141500e+00 : f64 | ||
|
||
// else, f64 is printed with 17 significant digits | ||
arith.constant 3.141592 : f64 | ||
// CHECK-NEXT: {{%.*}} = arith.constant 3.1415920000000002 : f64 |
This file contains 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 file contains 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
Oops, something went wrong.