-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Description
I have the following MLIR program:
test1.mlir:
module {
func.func nested @func1() -> f32 {
%c1 = arith.constant 1 : index
%alloc = memref.alloc() : memref<24xi32>
%0 = arith.constant 1 : i32
memref.store %0, %alloc[%c1] : memref<24xi32>
%false_22 = arith.constant false
%splat_23 = tensor.splat %false_22 : tensor<13x13x1xi1>
%splat_86 = tensor.splat %false_22 : tensor<13x13x1xi1>
%mapped = linalg.map ins(%splat_23, %splat_23 : tensor<13x13x1xi1>, tensor<13x13x1xi1>) outs(%splat_86 : tensor<13x13x1xi1>)
(%in: i1, %in_97: i1) {
%false_106 = arith.constant false
%2 = arith.constant 10 : i32
memref.store %2, %alloc[%c1] : memref<24xi32>
linalg.yield %false_106 : i1
}
%1 = memref.load %alloc[%c1] : memref<24xi32>
%111 = arith.sitofp %1 :i32 to f32
vector.print %1 : i32
return %111 : f32
}
}
When I ran /data/tmp/v1018/llvm-project/build/bin/mlir-opt --one-shot-bufferize="dialect-filter=tensor,linalg,bufferization" --expand-strided-metadata --func-bufferize --convert-linalg-to-loops --one-shot-bufferize="dialect-filter=arith" --convert-arith-to-llvm --lower-affine --finalize-memref-to-llvm --convert-index-to-llvm --convert-scf-to-cf --convert-func-to-llvm --convert-vector-to-llvm --convert-arith-to-llvm --reconcile-unrealized-casts test1.mlir | /data/tmp/v1018/llvm-project/build/bin/mlir-cpu-runner -e func1 --shared-libs=/data/tmp/v1018/llvm-project/build/lib/libmlir_runner_utils.so,/data/tmp/v1018/llvm-project/build/lib/libmlir_c_runner_utils.so on the program, I got the result of:
10
1.000000e+01
However, when I ran /data/tmp/v1018/llvm-project/build/bin/mlir-opt --linalg-named-op-conversion --one-shot-bufferize="dialect-filter=tensor,linalg,bufferization" --expand-strided-metadata --func-bufferize --convert-linalg-to-loops --one-shot-bufferize="dialect-filter=arith" --convert-arith-to-llvm --lower-affine --finalize-memref-to-llvm --convert-index-to-llvm --convert-scf-to-cf --convert-func-to-llvm --convert-vector-to-llvm --convert-arith-to-llvm --reconcile-unrealized-casts test1.mlir | /data/tmp/v1018/llvm-project/build/bin/mlir-cpu-runner -e func1 --shared-libs=/data/tmp/v1018/llvm-project/build/lib/libmlir_runner_utils.so,/data/tmp/v1018/llvm-project/build/lib/libmlir_c_runner_utils.so on the program, I got the result of:
1
1.000000e+00
The above two results seem to be inconsistent. I'm not sure if there is any bug in my program or if the wrong usage of the above passes caused these results.
Besides, the following MLIR program test2.mlir will cause similar inconsistent results using the same commands:
test2.mlir:
module {
func.func private @func1() -> f32 {
%c1 = arith.constant 1 : index
%alloc = memref.alloc() : memref<24xi32>
%0 = arith.constant 1 : i32
memref.store %0, %alloc[%c1] : memref<24xi32>
%c-22846_i32 = arith.constant -22846 : i32
%from_elements_108 = tensor.splat %c-22846_i32 : tensor<3xi32>
%from_elements_110 = tensor.splat %c-22846_i32 : tensor<3xi32>
%215 = linalg.generic {indexing_maps = [affine_map<(d0) -> (d0)>, affine_map<(d0) -> (d0)>], iterator_types = ["parallel"]} ins(%from_elements_108 : tensor<3xi32>) outs(%from_elements_110 : tensor<3xi32>) {
^bb0(%in: i32, %out: i32):
memref.store %in, %alloc[%c1] : memref<24xi32>
linalg.yield %in : i32
} -> tensor<3xi32>
%1 = memref.load %alloc[%c1] : memref<24xi32>
%111 = arith.sitofp %1 :i32 to f32
vector.print %1 : i32
return %111 : f32
}
}
My git version is 18ac017.