This addresses the issue reported in
I am not sure this is a good solution. Requiring from OffsetSizeAndStrideOpInterface users to to do such index manipulation is very inconvenient and error-prone. Maybe better to separate isDynamicDim APIs into 2 sets isInputDynamicDim/isOutputDynamicDim which can do index translation under the hood?
Also, locally I workarounded this by never using rank-reducing subview and instead implementing a custom op to do a rank reduction on memrefs (with this approach I can also precisely control, which dimensions I want to collapse, not just all-or-nothing).
I think this is fine, see the MLIR doc:
"fold has the restriction that no new operations may be created, and only the root operation may be replaced. It allows for updating an operation in-place, or returning a set of pre-existing values (or attributes) to replace the operation with"
Folders can mutate the op in place - in fact, the folder is prefered to a canonicalization pattern for such local op mutation because it lets the rewrite driver converge faster (to do more work early) -- since the folder would have run on it before the highest benefit canonicalization pattern is picked later in an iteration of the rewriter driver.