llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

`Dialect/Math/canonicalize.mlir` fails on trunk (`1e818cd8e262b402bd6d3cb380f83ca06966bb4b`)

Open ZolotukhinM opened this issue 4 years ago • 7 comments

I was trying to follow instructions on how to build LLVM-MLIR from https://mlir.llvm.org/getting_started/:

cmake -G Ninja ../llvm \
   -DLLVM_ENABLE_PROJECTS=mlir \
   -DLLVM_BUILD_EXAMPLES=ON \
   -DLLVM_TARGETS_TO_BUILD="host" \
   -DCMAKE_BUILD_TYPE=Release \
   -DLLVM_ENABLE_ASSERTIONS=ON
cmake --build . --target check-mlir

The build succeeded, but one test was failing:

FAIL: MLIR :: Dialect/Math/canonicalize.mlir (392 of 1458)
******************** TEST 'MLIR :: Dialect/Math/canonicalize.mlir' FAILED ********************
Script:
--
: 'RUN: at line 1';   /Users/mvz/dev/llvm-project/build/bin/mlir-opt /Users/mvz/dev/llvm-project/mlir/test/Dialect/Math/canonicalize.mlir -canonicalize | /Users/mvz/dev/llvm-project/build/bin/FileCheck /Users/mvz/dev/llvm-project/mlir/test/Dialect/Math/canonicalize.mlir
--
Exit Code: 1

Command Output (stderr):
--
/Users/mvz/dev/llvm-project/mlir/test/Dialect/Math/canonicalize.mlir:452:16: error: CHECK-NEXT: expected string not found in input
// CHECK-NEXT: %[[cst:.+]] = arith.constant 0.84{{[0-9]+}} : f32
               ^
<stdin>:200:21: note: scanning from here
 func.func @sin_fold() -> f32 {
                    ^
<stdin>:201:2: note: possible intended match here
 %cst = arith.constant 8.414710e-01 : f32
 ^
/Users/mvz/dev/llvm-project/mlir/test/Dialect/Math/canonicalize.mlir:461:16: error: CHECK-NEXT: expected string not found in input
// CHECK-NEXT: %[[cst:.+]] = arith.constant dense<[0.000000e+00, 0.84{{[0-9]+}}, 0.000000e+00, 0.84{{[0-9]+}}]> : vector<4xf32>
               ^
<stdin>:204:25: note: scanning from here
 func.func @sin_fold_vec() -> vector<4xf32> {
                        ^
<stdin>:205:2: note: possible intended match here
 %cst = arith.constant dense<[0.000000e+00, 8.414710e-01, 0.000000e+00, 8.414710e-01]> : vector<4xf32>
 ^

Input file: <stdin>
Check file: /Users/mvz/dev/llvm-project/mlir/test/Dialect/Math/canonicalize.mlir

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            .
            .
            .
          195:  }
          196:  func.func @trunc_fold_vec() -> vector<4xf32> {
          197:  %cst = arith.constant dense<[0.000000e+00, -0.000000e+00, 1.000000e+00, -1.000000e+00]> : vector<4xf32>
          198:  return %cst : vector<4xf32>
          199:  }
          200:  func.func @sin_fold() -> f32 {
next:452'0                         X~~~~~~~~~~~ error: no match found
          201:  %cst = arith.constant 8.414710e-01 : f32
next:452'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
next:452'1      ?                                         possible intended match
          202:  return %cst : f32
next:452'0     ~~~~~~~~~~~~~~~~~~~
          203:  }
next:452'0     ~~~
          204:  func.func @sin_fold_vec() -> vector<4xf32> {
next:452'0     ~~~~~~~~~~~~~~~~~~~~~~~~
next:461'0                             X~~~~~~~~~~~~~~~~~~~~~ error: no match found
          205:  %cst = arith.constant dense<[0.000000e+00, 8.414710e-01, 0.000000e+00, 8.414710e-01]> : vector<4xf32>
next:461'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
next:461'1      ?                                                                                                      possible intended match
          206:  return %cst : vector<4xf32>
next:461'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          207:  }
next:461'0     ~~~
          208:  func.func @erf_fold() -> f32 {
next:461'0     ~~~~~~~~~~~~~~~~~~~~
          209:  %cst = arith.constant 0.842700779 : f32
          210:  return %cst : f32
            .
            .
            .
>>>>>>

--

********************
********************
Failed Tests (1):
  MLIR :: Dialect/Math/canonicalize.mlir

It was AArch64 build on M1 MacBook.

ZolotukhinM avatar Sep 28 '22 21:09 ZolotukhinM

@llvm/issue-subscribers-mlir

llvmbot avatar Sep 28 '22 22:09 llvmbot

@jacquesguan can you take a look at this?

Mogball avatar Sep 28 '22 22:09 Mogball

https://reviews.llvm.org/D134850 I create a revision for this, it should work, but I do not have M1 environment to test it.

jacquesguan avatar Sep 29 '22 03:09 jacquesguan

I had the same issue on my M1 Max Macbook. The issue was caused by the exponential notation of floating point numbers. The canonicalization results of some floating point operations are printed in the exponential notation like "8.414710e-01" on my environment, but some tests try to match the results with "0.84{{[0-9]+}}". I don't know whether the issue caused by the gap of floating point notations occurs only on M1 Mac or not, but all the tests are passed after changing "0.84{{[0-9]+}}" to "8.4{{[0-9]}}e-01".

SunghoLee avatar Oct 07 '22 07:10 SunghoLee

I don't know whether the issue caused by the gap of floating point notations occurs only on M1 Mac or not, but all the tests are passed after changing "0.84{{[0-9]+}}" to "8.4{{[0-9]}}e-01".

This will cause the test to fail on other platforms, unfortunately.

Mogball avatar Oct 10 '22 16:10 Mogball

I don't know whether the issue caused by the gap of floating point notations occurs only on M1 Mac or not, but all the tests are passed after changing "0.84{{[0-9]+}}" to "8.4{{[0-9]}}e-01".

This will cause the test to fail on other platforms, unfortunately.

Agreed. Then, how about changing it to "{{0.84[0-9]+|8.4[0-9]+e-01}}" for both Mac and other platforms?

SunghoLee avatar Oct 11 '22 01:10 SunghoLee

It looks like this issue can be closed because https://reviews.llvm.org/D134850 was merged?

rikhuijzer avatar May 27 '23 20:05 rikhuijzer