[mlir] Inconsistent output when executing MLIR program with `linalg-specialize-generic-ops`
git version: https://github.com/llvm/llvm-project/commit/2172a5edcf9357d24006a3c1032f2d52e199915d
system: Ubuntu 18.04.6 LTS
Description:
I am experiencing an inconsistent result when executing the same MLIR program with and without linalg-specialize-generic-ops.
Steps to Reproduce:
1. MLIR Program (a.mlir):
a.mlir:
module {
func.func private @printMemrefI32(tensor<*xi32>)
func.func private @printMemrefF32(tensor<*xf32>)
func.func @main() -> () {
%arg0 = index.constant 0
%6 = "tosa.const"() <{values = dense<-132> : tensor<1x2x1xi32>}> : () -> tensor<1x2x1xi32>
%11 = tosa.cast %6 : (tensor<1x2x1xi32>) -> tensor<1x2x1xf32>
%15 = "tosa.const"() <{values = dense<0> : tensor<1x2x1xi32>}> : () -> tensor<1x2x1xi32>
%16 = tosa.while_loop (%arg1 = %15) : (tensor<1x2x1xi32>) -> tensor<1x2x1xi32> {
%40 = "tosa.const"() <{values = dense<3> : tensor<1x2x1xi32>}> : () -> tensor<1x2x1xi32>
%41 = tosa.greater %40, %arg1 : (tensor<1x2x1xi32>, tensor<1x2x1xi32>) -> tensor<1x2x1xi1>
%extracted = tensor.extract %41[%arg0, %arg0, %arg0] : tensor<1x2x1xi1>
%from_elements = tensor.from_elements %extracted : tensor<i1>
tosa.yield %from_elements : tensor<i1>
} do {
^bb0(%arg1: tensor<1x2x1xi32>):
%45 = "tosa.const"() <{values = dense<1> : tensor<1x2x1xi32>}> : () -> tensor<1x2x1xi32>
%46 = tosa.add %arg1, %45 : (tensor<1x2x1xi32>, tensor<1x2x1xi32>) -> tensor<1x2x1xi32>
tosa.yield %46 : tensor<1x2x1xi32>
}
%17 = tosa.clamp %16 {max_val = 1073741823 : i32, min_val = -1073741824 : i32} : (tensor<1x2x1xi32>) -> tensor<1x2x1xi32>
%18 = tosa.clamp %16 {max_val = 1073741823 : i32, min_val = -1073741824 : i32} : (tensor<1x2x1xi32>) -> tensor<1x2x1xi32>
%19 = tosa.sub %17, %18 : (tensor<1x2x1xi32>, tensor<1x2x1xi32>) -> tensor<1x2x1xi32>
%cast19 = tensor.cast %19 : tensor<1x2x1xi32> to tensor<*xi32>
call @printMemrefI32(%cast19) : (tensor<*xi32>) -> ()
return
}
}
2. Command to Run without linalg-specialize-generic-ops :
/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt /data/szy/workspace/mlir-inconsistent/a.mlir -pass-pipeline="builtin.module(func.func(tosa-to-linalg-named))" \
| /data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt -tosa-to-scf \
| /data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt -pass-pipeline="builtin.module(func.func(tosa-to-linalg))" \
| /data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt -tosa-to-tensor -tosa-to-arith -convert-scf-to-cf -convert-math-to-llvm \
--linalg-fuse-elementwise-ops --cse --linalg-generalize-named-ops -convert-arith-to-llvm \
-one-shot-bufferize="bufferize-function-boundaries" --linalg-fold-unit-extent-dims -finalize-memref-to-llvm --expand-strided-metadata --linalg-specialize-generic-ops \
-convert-linalg-to-affine-loops -convert-index-to-llvm -finalize-memref-to-llvm -lower-affine -convert-scf-to-cf \
-convert-arith-to-llvm -convert-cf-to-llvm -finalize-memref-to-llvm -convert-func-to-llvm -reconcile-unrealized-casts \
| timeout 10 /data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-cpu-runner -e main -entry-point-result=void \
--shared-libs=/data/szy/MLIR/llvm-release/llvm-project/build/lib/libmlir_c_runner_utils.so \
--shared-libs=/data/szy/MLIR/llvm-release/llvm-project/build/lib/libmlir_runner_utils.so \
--shared-libs=/data/szy/MLIR/llvm-release/llvm-project/build/lib/libmlir_async_runtime.so
3. Output without linalg-specialize-generic-ops ::
[[[0],
[0]]]
4. Command to Run with linalg-specialize-generic-ops :
/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt /data/szy/workspace/mlir-inconsistent/a.mlir -pass-pipeline="builtin.module(func.func(tosa-to-linalg-named))" \
| /data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt -tosa-to-scf \
| /data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt -pass-pipeline="builtin.module(func.func(tosa-to-linalg))" \
| /data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt -tosa-to-tensor -tosa-to-arith -convert-scf-to-cf -convert-math-to-llvm \
--linalg-fuse-elementwise-ops --cse --linalg-generalize-named-ops -convert-arith-to-llvm \
-one-shot-bufferize="bufferize-function-boundaries" --linalg-fold-unit-extent-dims -finalize-memref-to-llvm --expand-strided-metadata \
-convert-linalg-to-affine-loops -convert-index-to-llvm -finalize-memref-to-llvm -lower-affine -convert-scf-to-cf \
-convert-arith-to-llvm -convert-cf-to-llvm -finalize-memref-to-llvm -convert-func-to-llvm -reconcile-unrealized-casts \
| timeout 10 /data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-cpu-runner -e main -entry-point-result=void \
--shared-libs=/data/szy/MLIR/llvm-release/llvm-project/build/lib/libmlir_c_runner_utils.so \
--shared-libs=/data/szy/MLIR/llvm-release/llvm-project/build/lib/libmlir_runner_utils.so \
--shared-libs=/data/szy/MLIR/llvm-release/llvm-project/build/lib/libmlir_async_runtime.so
5. Output with linalg-specialize-generic-ops :
[[[3],
[3]]]
6. Analysis for this case :
I debug this issue and find the faulty pass is linalg-specialize-generic-ops
The input IR (ir before running the linalg-specialize-generic-ops) can be found in input.txt
The output IR (ir after running thelinalg-specialize-generic-ops) can be found in output.txt
Please change file from .txt to .mlir
This MLIR program is expected to correctly output [0, 0] for %19 = tosa.sub %17, %18, given that %17 and %18 are both equal to %16. However, instead of the expected result, it incorrectly outputs [3, 3], which is the value of %16.
To debug this issue, I printed the IR after each pass and found that the input IR input.txt is correct before applying the --linalg-specialize-generic-ops pass. As shown in the first image, %reinterpret_cast_24 (the final result) is stored the value of %9, which is a constant with the value 0. However, after running --linalg-specialize-generic-ops output.txt , in the second image the linalg.generic operation is mistakenly optimized into linalg.copy, propagating the value 3 from %reinterpret_cast_19 to %reinterpret_cast_24, ultimately leading to the incorrect final result.
@llvm/issue-subscribers-mlir
Author: None (Emilyaxe)
system: Ubuntu 18.04.6 LTS
Description:
I am experiencing an inconsistent result when executing the same MLIR program with and without linalg-specialize-generic-ops.
Steps to Reproduce:
1. MLIR Program (a.mlir):
a.mlir:
module {
func.func private @<!-- -->printMemrefI32(tensor<*xi32>)
func.func private @<!-- -->printMemrefF32(tensor<*xf32>)
func.func @<!-- -->main() -> () {
%arg0 = index.constant 0
%6 = "tosa.const"() <{value = dense<-132> : tensor<1x2x1xi32>}> : () -> tensor<1x2x1xi32>
%11 = tosa.cast %6 : (tensor<1x2x1xi32>) -> tensor<1x2x1xf32>
%15 = "tosa.const"() <{value = dense<0> : tensor<1x2x1xi32>}> : () -> tensor<1x2x1xi32>
%16 = tosa.while_loop (%arg1 = %15) : (tensor<1x2x1xi32>) -> tensor<1x2x1xi32> {
%40 = "tosa.const"() <{value = dense<3> : tensor<1x2x1xi32>}> : () -> tensor<1x2x1xi32>
%41 = tosa.greater %40, %arg1 : (tensor<1x2x1xi32>, tensor<1x2x1xi32>) -> tensor<1x2x1xi1>
%extracted = tensor.extract %41[%arg0, %arg0, %arg0] : tensor<1x2x1xi1>
%from_elements = tensor.from_elements %extracted : tensor<i1>
tosa.yield %from_elements : tensor<i1>
} do {
^bb0(%arg1: tensor<1x2x1xi32>):
%40 = tosa.sin %11 : (tensor<1x2x1xf32>) -> tensor<1x2x1xf32>
%41 = tosa.slice %11 {size = array<i64: 1, 5, 6>, start = array<i64: 0, 9, 25>} : (tensor<1x2x1xf32>) -> tensor<1x5x6xf32>
%42 = tosa.erf %11 : (tensor<1x2x1xf32>) -> tensor<1x2x1xf32>
%43 = tosa.reverse %11 {axis = 0 : i32} : (tensor<1x2x1xf32>) -> tensor<1x2x1xf32>
%44 = tosa.greater_equal %41, %41 : (tensor<1x5x6xf32>, tensor<1x5x6xf32>) -> tensor<1x5x6xi1>
%45 = "tosa.const"() <{value = dense<1> : tensor<1x2x1xi32>}> : () -> tensor<1x2x1xi32>
%46 = tosa.add %arg1, %45 : (tensor<1x2x1xi32>, tensor<1x2x1xi32>) -> tensor<1x2x1xi32>
tosa.yield %46 : tensor<1x2x1xi32>
}
%17 = tosa.clamp %16 {max_fp = 1.07374182E+9 : f32, max_int = 1073741823 : i64, min_fp = -1.07374182E+9 : f32, min_int = -1073741824 : i64} : (tensor<1x2x1xi32>) -> tensor<1x2x1xi32>
%18 = tosa.clamp %16 {max_fp = 1.07374182E+9 : f32, max_int = 1073741823 : i64, min_fp = -1.07374182E+9 : f32, min_int = -1073741824 : i64} : (tensor<1x2x1xi32>) -> tensor<1x2x1xi32>
%19 = tosa.sub %17, %18 : (tensor<1x2x1xi32>, tensor<1x2x1xi32>) -> tensor<1x2x1xi32>
%cast19 = tensor.cast %19 : tensor<1x2x1xi32> to tensor<*xi32>
call @<!-- -->printMemrefI32(%cast19) : (tensor<*xi32>) -> ()
return
}
}
2. Command to Run without linalg-specialize-generic-ops :
/data/szy/MLIR/llvm-release/llvm-project/install/mlir-opt /data/szy/workspace/mlir-inconsistent/a.mlir -pass-pipeline="builtin.module(func.func(tosa-to-linalg-named))" \
| /data/szy/MLIR/llvm-release/llvm-project/install/mlir-opt -tosa-to-scf \
| /data/szy/MLIR/llvm-release/llvm-project/install/mlir-opt -pass-pipeline="builtin.module(func.func(tosa-to-linalg))" \
| /data/szy/MLIR/llvm-release/llvm-project/install/mlir-opt -tosa-to-tensor -tosa-to-arith -convert-scf-to-cf -convert-math-to-llvm \
--linalg-fuse-elementwise-ops --cse --linalg-generalize-named-ops -convert-arith-to-llvm \
-one-shot-bufferize="bufferize-function-boundaries" --linalg-fold-unit-extent-dims -finalize-memref-to-llvm --expand-strided-metadata \
-convert-linalg-to-affine-loops -convert-cf-to-llvm -convert-index-to-llvm -finalize-memref-to-llvm -lower-affine -convert-scf-to-cf \
-convert-arith-to-llvm -finalize-memref-to-llvm -convert-func-to-llvm -reconcile-unrealized-casts \
| timeout 10 /data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-cpu-runner -e main -entry-point-result=void \
--shared-libs=/data/szy/MLIR/llvm-release/llvm-project/build/lib/libmlir_c_runner_utils.so \
--shared-libs=/data/szy/MLIR/llvm-release/llvm-project/build/lib/libmlir_runner_utils.so \
--shared-libs=/data/szy/MLIR/llvm-release/llvm-project/build/lib/libmlir_async_runtime.so
3. Output without linalg-specialize-generic-ops ::
[[[0],
[0]]]
4. Command to Run with linalg-specialize-generic-ops :
/data/szy/MLIR/llvm-release/llvm-project/install/mlir-opt /data/szy/workspace/mlir-inconsistent/a.mlir -pass-/data/szy/MLIR/llvm-release/llvm-project/install/mlir-opt /data/szy/workspace/mlir-inconsistent/a.mlir -pass-pipeline="builtin.module(func.func(tosa-to-linalg-named))" \
| /data/szy/MLIR/llvm-release/llvm-project/install/mlir-opt -tosa-to-scf \
| /data/szy/MLIR/llvm-release/llvm-project/install/mlir-opt -pass-pipeline="builtin.module(func.func(tosa-to-linalg))" \
| /data/szy/MLIR/llvm-release/llvm-project/install/mlir-opt -tosa-to-tensor -tosa-to-arith -convert-scf-to-cf -convert-math-to-llvm \
--linalg-fuse-elementwise-ops --cse --linalg-generalize-named-ops -convert-arith-to-llvm \
-one-shot-bufferize="bufferize-function-boundaries" --linalg-fold-unit-extent-dims -finalize-memref-to-llvm --expand-strided-metadata \
--linalg-specialize-generic-ops -convert-linalg-to-affine-loops -convert-cf-to-llvm -convert-index-to-llvm -finalize-memref-to-llvm -lower-affine -convert-scf-to-cf \
-convert-arith-to-llvm -finalize-memref-to-llvm -convert-func-to-llvm -reconcile-unrealized-casts \
| timeout 10 /data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-cpu-runner -e main -entry-point-result=void \
--shared-libs=/data/szy/MLIR/llvm-release/llvm-project/build/lib/libmlir_c_runner_utils.so \
--shared-libs=/data/szy/MLIR/llvm-release/llvm-project/build/lib/libmlir_runner_utils.so \
--shared-libs=/data/szy/MLIR/llvm-release/llvm-project/build/lib/libmlir_async_runtime.so
5. Output with linalg-specialize-generic-ops :
[[[3],
[3]]]
6. Analysis for this case :
This MLIR program is expected to correctly output [0, 0] for %19 = tosa.sub %17, %18, given that %17 and %18 are both equal to %16. However, instead of the expected result, it incorrectly outputs [3, 3], which is the value of %16.
To debug this issue, I printed the IR after each pass and found that the input IR input.txt is correct before applying the --linalg-specialize-generic-ops pass. As shown in the first image, %reinterpret_cast_24 (the final result) is stored the value of %9, which is a constant with the value 0. However, after running --linalg-specialize-generic-ops output.txt , in the second image the linalg.generic operation is mistakenly optimized into linalg.copy, propagating the value 3 from %reinterpret_cast_19 to %reinterpret_cast_24, ultimately leading to the incorrect final result.
@llvm/issue-subscribers-mlir-linalg
Author: None (Emilyaxe)
system: Ubuntu 18.04.6 LTS
Description:
I am experiencing an inconsistent result when executing the same MLIR program with and without linalg-specialize-generic-ops.
Steps to Reproduce:
1. MLIR Program (a.mlir):
a.mlir:
module {
func.func private @<!-- -->printMemrefI32(tensor<*xi32>)
func.func private @<!-- -->printMemrefF32(tensor<*xf32>)
func.func @<!-- -->main() -> () {
%arg0 = index.constant 0
%6 = "tosa.const"() <{value = dense<-132> : tensor<1x2x1xi32>}> : () -> tensor<1x2x1xi32>
%11 = tosa.cast %6 : (tensor<1x2x1xi32>) -> tensor<1x2x1xf32>
%15 = "tosa.const"() <{value = dense<0> : tensor<1x2x1xi32>}> : () -> tensor<1x2x1xi32>
%16 = tosa.while_loop (%arg1 = %15) : (tensor<1x2x1xi32>) -> tensor<1x2x1xi32> {
%40 = "tosa.const"() <{value = dense<3> : tensor<1x2x1xi32>}> : () -> tensor<1x2x1xi32>
%41 = tosa.greater %40, %arg1 : (tensor<1x2x1xi32>, tensor<1x2x1xi32>) -> tensor<1x2x1xi1>
%extracted = tensor.extract %41[%arg0, %arg0, %arg0] : tensor<1x2x1xi1>
%from_elements = tensor.from_elements %extracted : tensor<i1>
tosa.yield %from_elements : tensor<i1>
} do {
^bb0(%arg1: tensor<1x2x1xi32>):
%40 = tosa.sin %11 : (tensor<1x2x1xf32>) -> tensor<1x2x1xf32>
%41 = tosa.slice %11 {size = array<i64: 1, 5, 6>, start = array<i64: 0, 9, 25>} : (tensor<1x2x1xf32>) -> tensor<1x5x6xf32>
%42 = tosa.erf %11 : (tensor<1x2x1xf32>) -> tensor<1x2x1xf32>
%43 = tosa.reverse %11 {axis = 0 : i32} : (tensor<1x2x1xf32>) -> tensor<1x2x1xf32>
%44 = tosa.greater_equal %41, %41 : (tensor<1x5x6xf32>, tensor<1x5x6xf32>) -> tensor<1x5x6xi1>
%45 = "tosa.const"() <{value = dense<1> : tensor<1x2x1xi32>}> : () -> tensor<1x2x1xi32>
%46 = tosa.add %arg1, %45 : (tensor<1x2x1xi32>, tensor<1x2x1xi32>) -> tensor<1x2x1xi32>
tosa.yield %46 : tensor<1x2x1xi32>
}
%17 = tosa.clamp %16 {max_fp = 1.07374182E+9 : f32, max_int = 1073741823 : i64, min_fp = -1.07374182E+9 : f32, min_int = -1073741824 : i64} : (tensor<1x2x1xi32>) -> tensor<1x2x1xi32>
%18 = tosa.clamp %16 {max_fp = 1.07374182E+9 : f32, max_int = 1073741823 : i64, min_fp = -1.07374182E+9 : f32, min_int = -1073741824 : i64} : (tensor<1x2x1xi32>) -> tensor<1x2x1xi32>
%19 = tosa.sub %17, %18 : (tensor<1x2x1xi32>, tensor<1x2x1xi32>) -> tensor<1x2x1xi32>
%cast19 = tensor.cast %19 : tensor<1x2x1xi32> to tensor<*xi32>
call @<!-- -->printMemrefI32(%cast19) : (tensor<*xi32>) -> ()
return
}
}
2. Command to Run without linalg-specialize-generic-ops :
/data/szy/MLIR/llvm-release/llvm-project/install/mlir-opt /data/szy/workspace/mlir-inconsistent/a.mlir -pass-pipeline="builtin.module(func.func(tosa-to-linalg-named))" \
| /data/szy/MLIR/llvm-release/llvm-project/install/mlir-opt -tosa-to-scf \
| /data/szy/MLIR/llvm-release/llvm-project/install/mlir-opt -pass-pipeline="builtin.module(func.func(tosa-to-linalg))" \
| /data/szy/MLIR/llvm-release/llvm-project/install/mlir-opt -tosa-to-tensor -tosa-to-arith -convert-scf-to-cf -convert-math-to-llvm \
--linalg-fuse-elementwise-ops --cse --linalg-generalize-named-ops -convert-arith-to-llvm \
-one-shot-bufferize="bufferize-function-boundaries" --linalg-fold-unit-extent-dims -finalize-memref-to-llvm --expand-strided-metadata \
-convert-linalg-to-affine-loops -convert-cf-to-llvm -convert-index-to-llvm -finalize-memref-to-llvm -lower-affine -convert-scf-to-cf \
-convert-arith-to-llvm -finalize-memref-to-llvm -convert-func-to-llvm -reconcile-unrealized-casts \
| timeout 10 /data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-cpu-runner -e main -entry-point-result=void \
--shared-libs=/data/szy/MLIR/llvm-release/llvm-project/build/lib/libmlir_c_runner_utils.so \
--shared-libs=/data/szy/MLIR/llvm-release/llvm-project/build/lib/libmlir_runner_utils.so \
--shared-libs=/data/szy/MLIR/llvm-release/llvm-project/build/lib/libmlir_async_runtime.so
3. Output without linalg-specialize-generic-ops ::
[[[0],
[0]]]
4. Command to Run with linalg-specialize-generic-ops :
/data/szy/MLIR/llvm-release/llvm-project/install/mlir-opt /data/szy/workspace/mlir-inconsistent/a.mlir -pass-/data/szy/MLIR/llvm-release/llvm-project/install/mlir-opt /data/szy/workspace/mlir-inconsistent/a.mlir -pass-pipeline="builtin.module(func.func(tosa-to-linalg-named))" \
| /data/szy/MLIR/llvm-release/llvm-project/install/mlir-opt -tosa-to-scf \
| /data/szy/MLIR/llvm-release/llvm-project/install/mlir-opt -pass-pipeline="builtin.module(func.func(tosa-to-linalg))" \
| /data/szy/MLIR/llvm-release/llvm-project/install/mlir-opt -tosa-to-tensor -tosa-to-arith -convert-scf-to-cf -convert-math-to-llvm \
--linalg-fuse-elementwise-ops --cse --linalg-generalize-named-ops -convert-arith-to-llvm \
-one-shot-bufferize="bufferize-function-boundaries" --linalg-fold-unit-extent-dims -finalize-memref-to-llvm --expand-strided-metadata \
--linalg-specialize-generic-ops -convert-linalg-to-affine-loops -convert-cf-to-llvm -convert-index-to-llvm -finalize-memref-to-llvm -lower-affine -convert-scf-to-cf \
-convert-arith-to-llvm -finalize-memref-to-llvm -convert-func-to-llvm -reconcile-unrealized-casts \
| timeout 10 /data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-cpu-runner -e main -entry-point-result=void \
--shared-libs=/data/szy/MLIR/llvm-release/llvm-project/build/lib/libmlir_c_runner_utils.so \
--shared-libs=/data/szy/MLIR/llvm-release/llvm-project/build/lib/libmlir_runner_utils.so \
--shared-libs=/data/szy/MLIR/llvm-release/llvm-project/build/lib/libmlir_async_runtime.so
5. Output with linalg-specialize-generic-ops :
[[[3],
[3]]]
6. Analysis for this case :
This MLIR program is expected to correctly output [0, 0] for %19 = tosa.sub %17, %18, given that %17 and %18 are both equal to %16. However, instead of the expected result, it incorrectly outputs [3, 3], which is the value of %16.
To debug this issue, I printed the IR after each pass and found that the input IR input.txt is correct before applying the --linalg-specialize-generic-ops pass. As shown in the first image, %reinterpret_cast_24 (the final result) is stored the value of %9, which is a constant with the value 0. However, after running --linalg-specialize-generic-ops output.txt , in the second image the linalg.generic operation is mistakenly optimized into linalg.copy, propagating the value 3 from %reinterpret_cast_19 to %reinterpret_cast_24, ultimately leading to the incorrect final result.
@javedabsar , assigned this one to you as our expert in the area :)
@Emilyaxe please could you share the linalg out of tosa. For me the above tosa IR gives error $ ./build/bin/mlir-opt -pass-pipeline="builtin.module(func.func(tosa-to-linalg-named))" tosa.mlir tosa.mlir:18:13: error: 'tosa.slice' op expected 3 operands, but found 1 %41 = tosa.slice %11 {size = array<i64: 1, 5, 6>, start = array<i64: 0, 9, 25>} : (tensor<1x2x1xf32>) -> tensor<1x5x6xf32> ^ tosa.mlir:18:13: note: see current operation: %10 = "tosa.slice"(%2) {size = array<i64: 1, 5, 6>, start = array<i64: 0, 9, 25>} : (tensor<1x2x1xf32>) -> tensor<1x5x6xf32>
Hi @javedabsar1,
Thank you for your quick reply.
Sorry for the confusion—the TOSA program cannot be compiled with the latest version of mlir-opt.
The corresponding Linalg out of tosa ( input IR ) can be found in input-3.txt, and the output IR after running --linalg-specialize-generic-ops is available in output-3.txt. Please note that you should rename the files from .txt to .mlir before use.
The following commands can be used to generate the results. This command is compatible with the latest version (d6c0839c9c82375).
/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt input.mlir \
--linalg-specialize-generic-ops -convert-linalg-to-affine-loops -convert-cf-to-llvm -convert-index-to-llvm -finalize-memref-to-llvm -lower-affine -convert-scf-to-cf -convert-cf-to-llvm \
-convert-arith-to-llvm -finalize-memref-to-llvm -convert-func-to-llvm -reconcile-unrealized-casts \
| timeout 10 /data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-cpu-runner -e main -entry-point-result=void \
--shared-libs=/data/szy/MLIR/llvm-release/llvm-project/build/lib/libmlir_c_runner_utils.so \
--shared-libs=/data/szy/MLIR/llvm-release/llvm-project/build/lib/libmlir_runner_utils.so \
--shared-libs=/data/szy/MLIR/llvm-release/llvm-project/build/lib/libmlir_async_runtime.so
I have updated the case to reproduce the bug in the latest version (https://github.com/llvm/llvm-project/commit/2172a5edcf9357d24006a3c1032f2d52e199915d), and I have also provided the input and output IR before and after the suspicious pass.
Hi, @javedabsar1 , are you still check this issue? If not, I can open a PR to fix it.