Open llvmbot opened 3 years ago
According to your suggestion, I found a test case that can be executed normally. Thank you very much for your patient reply. By the way, maybe the official document should give some additional instructions to avoid this situation again.
Julian: is this in your scope to update this doc?
Wen: you'll have better chance to find working sample in the test directory, grep
for the pass name you're looking for and you'll find working test-cases.
The complete sample file comes from the input of "-buffer-deallocation" in the pass introduction document of MLIR:
#map0 = affine_map<(d0) -> (d0)>
module {
func @​condBranch(%arg0: i1, %arg1: memref<2xf32>, %arg2: memref<2xf32>) {
cond_br %arg0, ^bb1, ^bb2
^bb1:
br ^bb3(%arg1: memref<2xf32>)
^bb2:
%0 = alloc(): memref<2xf32>
linalg.generic {
args_in = 1: i64,
args_out = 1: i64,
indexing_maps = [#map0, #map0],
iterator_types = ["parallel"]} %arg1, %0 {
^bb0(%gen1_arg0: f32, %gen1_arg1: f32):
%tmp1 = exp %gen1_arg0: f32
linalg.yield %tmp1: f32
}: memref<2xf32>, memref<2xf32>
br ^bb3(%0: memref<2xf32>)
^bb3(%1: memref<2xf32>):
"linalg.copy"(%1, %arg2): (memref<2xf32>, memref<2xf32>) -> ()
return
}
}
The modified file is:
#map0 = affine_map<(d0) -> (d0)>
module {
func @​condBranch(%arg0: i1, %arg1: memref<2xf32>, %arg2: memref<2xf32>) {
cond_br %arg0, ^bb1, ^bb2
^bb1:
br ^bb3(%arg1: memref<2xf32>)
^bb2:
%0 = memref.alloc(): memref<2xf32>
linalg.generic {
args_in = 1: i64,
args_out = 1: i64,
indexing_maps = [#map0, #map0],
iterator_types = ["parallel"]} %arg1, %0 {
^bb0(%gen1_arg0: f32, %gen1_arg1: f32):
%tmp1 = exp %gen1_arg0: f32
linalg.yield %tmp1: f32
}: memref<2xf32>, memref<2xf32>
br ^bb3(%0: memref<2xf32>)
^bb3(%1: memref<2xf32>):
"linalg.copy"(%1, %arg2): (memref<2xf32>, memref<2xf32>) -> ()
return
}
}
My guess is that the file sample.mlir contains an older syntax and can't be parsed by the version of MLIR you're using. Can you the entire content?
Sorry, the output of mlir is indeed memref.aiioc(), I see it as the result in the documentation. alloc() is the reason why the document is not updated synchronously, so what about the second error?
./mlir-opt -buffer-deallocation sample.mlir
sample.mlir:13:38: error: expected'{' to begin a region iterator_types = ["parallel"]} %arg1, %0 { ^ What is the cause of this error?
It's likely that the doc is out-of-sync, we should fix this.
sample.mlir:8:10: error: custom op 'alloc' is unknown
%0 = alloc() : memref<2xf32>
^
alloc
used to be valid, but has been moved to the memref dialect a few months ago.
when I reproduced the toy tutorial, I found that the output mlir used alloc() instead of memref.alloc().
I don't expect this, can you past instruction and/or a sample of the output here?
Extended Description
Hello, I built MLIR according to the introduction of MLIR official website, and then reproduced the samples of each pass introduced in the pass document (https://mlir.llvm.org/docs/Passes/) according to mlir-opt . However, it was found that the mlir-opt module could not correctly identify the sample when it was reproduced.
Command:
./mlir-opt -buffer-deallocation sample.mlir
Output:
sample.mlir:8:10: error: custom op 'alloc' is unknown %0 = alloc() : memref<2xf32> ^
After checking some information, I changed alloc() in the sample file to memref.alloc(), but the following error was reported:
Command:
./mlir-opt -buffer-deallocation sample.mlir
Output:
sample.mlir:13:38: error: expected '{' to begin a region iterator_types = ["parallel"]} %arg1, %0 { ^ I guess these are two different formats of mlir, because when I reproduced the toy tutorial, I found that the output mlir used alloc() instead of memref.alloc(). In this case, when I want to use mlir-opt for optimization, do I need to make certain settings to adapt to different mlir formats? Or do I need to manually convert the format and then execute it?
Looking forward to your reply. thanks.