Now I’m using memref.subview, but I have a problem . I have spent a lot of time on it, but so the problem is still not solved.I hope someone can help me.Thanks!
- Why does the MemRefType of memref.subview created by c++ have strided?
you can see following code.The following code works fine.
%input0 = memref.get_global @input2 : memref<3x3x3xi8>
%subInput0 = memref.subview %input0[0, 0, 0][1, 3, 3][1, 1, 1] : memref<3x3x3xi8> to memref<3x3xi8>
But the subview
I created using c++ would look like this.The type of the result is memref<3x3xi8, strided<[3, 1]>>
.At first I set the type of the result to memref<3x3xi8>
,but it will report an error. Then I set the type of the result to memref<3x3xi8, strided<[3, 1]>>
,It will still report an error.
error: expected result type to be 'memref<1x3x3xi8, strided<[9, 3, 1], offset: 9>>' or a rank-reduced version. (mismatch of result layout)
%0 = "memref.get_global"() {name = @input2} : () -> memref<3x3x3xi8>
%1 = "memref.get_global"() {name = @input2} : () -> memref<3x3x3xi8>
%2 = "memref.alloc"() {operand_segment_sizes = array<i32: 0, 0>} : () -> memref<3x3x3xi8>
%3 = "memref.subview"(%0) {operand_segment_sizes = array<i32: 1, 0, 0, 0>, static_offsets = array<i64: 0, 0, 0>, static_sizes = array<i64: 1, 3, 3>, static_strides = array<i64: 1, 1, 1>} : (memref<3x3x3xi8>) -> memref<3x3xi8, strided<[3, 1]>>
%4 = "memref.subview"(%0) {operand_segment_sizes = array<i32: 1, 0, 0, 0>, static_offsets = array<i64: 1, 0, 0>, static_sizes = array<i64: 1, 3, 3>, static_strides = array<i64: 1, 1, 1>} : (memref<3x3x3xi8>) -> memref<3x3xi8, strided<[3, 1]>>
%5 = "memref.subview"(%0) {operand_segment_sizes = array<i32: 1, 0, 0, 0>, static_offsets = array<i64: 2, 0, 0>, static_sizes = array<i64: 1, 3, 3>, static_strides = array<i64: 1, 1, 1>} : (memref<3x3x3xi8>) -> memref<3x3xi8, strided<[3, 1]>>
You can see that directly making the result of type memref<3x3xi8> does not work in c++.
- How to solve this problem?
I’ve spent a lot of time working on this problem, but still can’t fix it.I don’t know where I should start to solve the problem now.I hope someone can point out where I’m wrong.I really need your help.Thanks!