Issue |
132172
|
Summary |
[MLIR] Inconsistent output when executing MLIR program with and without `-test-loop-fusion=test-loop-fusion-transformation`
|
Labels |
mlir
|
Assignees |
|
Reporter |
Lambor24
|
My git version is [6003c30](https://github.com/llvm/llvm-project/commit/6003c3055a4630be31cc3d459cdbb88248a007b9).
## Description:
I am experiencing an inconsistent result when executing the same MLIR program with and without the `-test-loop-fusion=test-loop-fusion-transformation`.
## Steps to Reproduce:
### 1. **MLIR Program (test.mlir)**:
test.mlir:
```
module {
memref.global "private" constant @__constant_5x1x2x3xi16 : memref<5x1x2x3xi16> = dense<81> {alignment = 64 : i64}
func.func private @printMemrefI16(memref<*xi16>) attributes {llvm.emit_c_interface}
func.func @main() {
%c81_i16 = arith.constant 81 : i16
%c1_i16 = arith.constant 1 : i16
%alloc = memref.alloc() {alignment = 64 : i64} : memref<1x2x3xi16>
affine.for %arg0 = 0 to 1 {
affine.for %arg1 = 0 to 2 {
affine.for %arg2 = 0 to 3 {
affine.store %c1_i16, %alloc[%arg0, %arg1, %arg2] : memref<1x2x3xi16>
}
}
}
affine.for %arg0 = 0 to 5 {
affine.for %arg1 = 0 to 1 {
affine.for %arg2 = 0 to 2 {
affine.for %arg3 = 0 to 3 {
%0 = affine.load %alloc[%arg1, %arg2, %arg3] : memref<1x2x3xi16>
%1 = arith.muli %0, %c81_i16 : i16
affine.store %1, %alloc[%arg1, %arg2, %arg3] : memref<1x2x3xi16>
}
}
}
}
%expand_shape = memref.expand_shape %alloc [[0, 1], [2], [3]] output_shape [1, 1, 2, 3] : memref<1x2x3xi16> into memref<1x1x2x3xi16>
%cast = memref.cast %expand_shape : memref<1x1x2x3xi16> to memref<*xi16>
call @printMemrefI16(%cast) : (memref<*xi16>) -> ()
return
}
}
```
### 2. **Command to Run Without `-test-loop-fusion=test-loop-fusion-transformation`:**
```
/path/llvm-project/build/bin/mlir-opt test.mlir -lower-affine -convert-scf-to-cf -expand-strided-metadata -convert-cf-to-llvm -convert-arith-to-llvm -convert-math-to-llvm -finalize-memref-to-llvm -convert-func-to-llvm -reconcile-unrealized-casts | \
/path/llvm-project/build/bin/mlir-runner -e main -entry-point-result=void \
-shared-libs=/path/llvm-project/build/lib/libmlir_runner_utils.so \
-shared-libs=/path/llvm-project/build/lib/libmlir_c_runner_utils.so \
-shared-libs=/path/llvm-project/build/lib/libmlir_async_runtime.so
```
### 3. **Output Without `-test-loop-fusion=test-loop-fusion-transformation`:**
```
[[[[7057, 7057, 7057],
[7057, 7057, 7057]]]]
```
### 4. **Command to Run With `-test-loop-fusion=test-loop-fusion-transformation`:**
```
/path/llvm-project/build/bin/mlir-opt test.mlir -test-loop-fusion=test-loop-fusion-transformation -lower-affine -convert-scf-to-cf -expand-strided-metadata -convert-cf-to-llvm -convert-arith-to-llvm -convert-math-to-llvm -finalize-memref-to-llvm -convert-func-to-llvm -reconcile-unrealized-casts | \
/path/llvm-project/build/bin/mlir-runner -e main -entry-point-result=void \
-shared-libs=/path/llvm-project/build/lib/libmlir_runner_utils.so \
-shared-libs=/path/llvm-project/build/lib/libmlir_c_runner_utils.so \
-shared-libs=/path/llvm-project/build/lib/libmlir_async_runtime.so
```
### 5. **Output With `-test-loop-fusion=test-loop-fusion-transformation`:**
```
[[[[81, 81, 81],
[81, 81, 81]]]]
```
I'm not sure if there is any bug in my program or if the wrong usage of the above passes caused this result.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs