I was writing an integration test with mlir-vulkan-runner. When I was initializing an input buffer using memref.store in an scf.for loop in the host function, I got an error that possibly resulted from finalize-memref-to-llvm in the pass pipeline of mlir-vulkan-runner (https://github.com/llvm/llvm-project/blob/main/mlir/tools/mlir-vulkan-runner/mlir-vulkan-runner.cpp#L78). I also tried using vector.store instead but still got the same error.
error: LLVM Translation failed for operation: builtin.unrealized_conversion_cast
Error: could not convert to LLVM IR
The host function is:
func.func @main() {
// Allocate 3 buffers.
%in_buf = memref.alloc() : memref<128xi32>
%out_buf = memref.alloc() : memref<1xi32>
%total_count_buf = memref.alloc() : memref<1xi32>
// Constants.
%cst0 = arith.constant 0 : i32
%idx0 = arith.constant 0 : index
%idx1 = arith.constant 1 : index
%idx32 = arith.constant 32 : index
%idx64 = arith.constant 64 : index
%idx65 = arith.constant 65 : index
%idx128 = arith.constant 128 : index
// Initialize input buffer.
// The input will be [0, 1, ..., 62, 63, 63, 62, ..., 1, 0]
scf.for %iter = %idx0 to %idx64 step %idx1 {
%iter_i32 = index.castu %iter : index to i32
memref.store %iter_i32, %in_buf[%iter] : memref<128xi32>
}
%cst127 = arith.constant 127 : i32
scf.for %iter = %idx65 to %idx128 step %idx1 {
%iter_i32 = index.castu %iter : index to i32
%elem = arith.subi %cst127, %iter_i32 : i32
memref.store %elem, %in_buf[%iter] : memref<128xi32>
}
// More code here...
}
I was writing an integration test with `mlir-vulkan-runner`. When I was initializing an input buffer using `memref.store` in an `scf.for` loop in the host function, I got an error that possibly resulted from `finalize-memref-to-llvm` in the pass pipeline of `mlir-vulkan-runner` (https://github.com/llvm/llvm-project/blob/main/mlir/tools/mlir-vulkan-runner/mlir-vulkan-runner.cpp#L78). I also tried using `vector.store` instead but still got the same error.
```
error: LLVM Translation failed for operation: builtin.unrealized_conversion_cast
Error: could not convert to LLVM IR
```
The host function is:
```
func.func @main() {
// Allocate 3 buffers.
%in_buf = memref.alloc() : memref<128xi32>
%out_buf = memref.alloc() : memref<1xi32>
%total_count_buf = memref.alloc() : memref<1xi32>
// Constants.
%cst0 = arith.constant 0 : i32
%idx0 = arith.constant 0 : index
%idx1 = arith.constant 1 : index
%idx32 = arith.constant 32 : index
%idx64 = arith.constant 64 : index
%idx65 = arith.constant 65 : index
%idx128 = arith.constant 128 : index
// Initialize input buffer.
// The input will be [0, 1, ..., 62, 63, 63, 62, ..., 1, 0]
scf.for %iter = %idx0 to %idx64 step %idx1 {
%iter_i32 = index.castu %iter : index to i32
memref.store %iter_i32, %in_buf[%iter] : memref<128xi32>
}
%cst127 = arith.constant 127 : i32
scf.for %iter = %idx65 to %idx128 step %idx1 {
%iter_i32 = index.castu %iter : index to i32
%elem = arith.subi %cst127, %iter_i32 : i32
memref.store %elem, %in_buf[%iter] : memref<128xi32>
}
// More code here...
}
```
I was writing an integration test with
mlir-vulkan-runner
. When I was initializing an input buffer usingmemref.store
in anscf.for
loop in the host function, I got an error that possibly resulted fromfinalize-memref-to-llvm
in the pass pipeline ofmlir-vulkan-runner
(https://github.com/llvm/llvm-project/blob/main/mlir/tools/mlir-vulkan-runner/mlir-vulkan-runner.cpp#L78). I also tried usingvector.store
instead but still got the same error.The host function is: