-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Open
Labels
Description
Take this example
func.func @strided_collapse (%in : memref<1x1x16x4x18xf32>) -> memref<1x16x64xf32, strided<[1152, 72, 1]>> {
%subview_7 = memref.subview %in[0, 0, 0, 0, 0] [1, 1, 16, 4, 16] [1, 1, 1, 1, 1] : memref<1x1x16x4x18xf32> to memref<1x1x16x4x16xf32, strided<[1152, 1152, 72, 18, 1]>>
%collapse_shape = memref.collapse_shape %subview_7 [[0], [1, 2], [3, 4]] : memref<1x1x16x4x16xf32, strided<[1152, 1152, 72, 18, 1]>> into memref<1x16x64xf32, strided<[1152, 72, 1]>>
return %collapse_shape : memref<1x16x64xf32, strided<[1152, 72, 1]>>
}
This is a correct op however we will get
> mlir-opt test.mlir
test.mlir:3:21: error: 'memref.collapse_shape' op invalid source layout map or collapsing non-contiguous dims
%collapse_shape = memref.collapse_shape %subview_7 [[0], [1, 2], [3, 4]] : memref<1x1x16x4x16xf32, strided<[1152, 1152, 72, 18, 1]>> into memref<1x16x64xf32, strided<[1152, 72, 1]>>
The reason is the verifier uses this function
https://github.com/llvm/llvm-project/blob/main/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp#L2416
which checks if the src and result strides match as a proof of contiguous collapse but that doesnt seem necessary?