See the included lit test: without this isReshapableDimBand change, it
fails to compile as it expects a different, dynamic-shape result memref
type:
mlir/test/Dialect/MemRef/ops.mlir:200:8: error: 'memref.collapse_shape' op expected collapsed type to be 'memref<?xf32, affine_map<(d0)[s0, s1] -> (d0 * s1 + s0)>>', but got 'memref<64xf32, affine_map<(d0)[s0] -> (d0 + s0)>>' %1 = memref.collapse_shape %arg [[0, 1, 2, 3]] : memref<1x1x8x8xf32, affine_map<(d0, d1, d2, d3)[s0, s1, s2] -> (d0 * s0 + d1 * s1 + s2 + d2 * 8 + d3)>> into memref<64xf32, affine_map<(d0)[s0] -> (d0 + s0)>> ^
Another thing is changed by this diff: dim -> idx in the
isDynamicSize check. I wasn't able to observe a practical impact of this
change on any test case, but it feels more correct? sizes[idx+1] is what
is being multiplied below, and if really dim had been intended, this
would have been moved out of the for loop, where dim is a constant.
While you're touching this, could you please s/extent/numDims ?
Seems confusing now that I read it months later..