Hi all. Is there semantically any difference between following two programs?:
The difference is offsets operand of memref.subview op ; memref.subview %3[%c0
vs memref.subview %3[0
module {
func private @foo(memref<30x30xi32>) -> i32
func @main() {
%c0 = arith.constant 0 : index
%3 = memref.alloca() : memref<1x30x30xi32>
%4 = memref.subview %3[%c0, 0, 0] [1, 30, 30] [1, 1, 1] : memref<1x30x30xi32> to memref<30x30xi32>
%7 = call @foo(%4) : (memref<30x30xi32>) -> i32
return
}
}
module {
func private @foo(memref<30x30xi32>) -> i32
func @main() {
%3 = memref.alloca() : memref<1x30x30xi32>
%4 = memref.subview %3[0, 0, 0] [1, 30, 30] [1, 1, 1] : memref<1x30x30xi32> to memref<30x30xi32>
%7 = call @foo(%4) : (memref<30x30xi32>) -> i32
return
}
}
Only for the first one, mlir-opt foo.mlir
gives me a following verification error.
(commit: cac164ff9cb671fae7a00d9a3adf1834ebca8bd9)
foo.mlir:6:10: error: expected result type to be 'memref<1x30x30xi32, affine_map<(d0, d1, d2)[s0] -> (d0 * 900 + s0 + d1 * 30 + d2)>>' or a rank-reduced version. (mismatch of result layout)
%4 = memref.subview %3[%c0, 0, 0] [1, 30, 30] [1, 1, 1] : memref<1x30x30xi32> to memref<30x30xi32>
^
foo.mlir:6:10: note: see current operation: %2 = "memref.subview"(%1, %0) {operand_segment_sizes = dense<[1, 1, 0, 0]> : vector<4xi32>, static_offsets = [-9223372036854775808, 0, 0], static_sizes = [1, 30, 30], static_strides = [1, 1, 1]} : (memref<1x30x30xi32>, index) -> memref<30x30xi32>
Also static_offsets being minus seems very weird