Rank-reducing memref.subview OffsetSizeAndStrideOpInterface interface issues

Yeah, I think a new interface (or new method on InferShapedTypeOpInterface) is needed here for the “sufficiently simple” cases that we want to be canonicalizations (probably the “resolves to existing operand” and “resolves to dim of existing operand”). OffsetSizeAndStrideOpInterface could provide helper functions, which assist in implementing this interface for “insert-like” and “extract-like” ops.

Although that will be interesting, because, for example, LinalgOp’s could implement SufficientlySimpleResultShapeInterface by always moving dim ops from results to “outs”, but I think we deliberately avoid that for other reasons.

Thanks, as I mentioned before I workarounded original issue locally by using custom op to do rank reduction after subview. I have tried to replace custom op with linalg.collapse_shape but it don’t have llvm lowering for my specific case (collapsing dynamic dim with number of static 1s dims). Is there any active work on supporting this? Supporting this specific lowering case seems straightforward on the first glance and I can try to implement it myself.

FYI, I will start working on linalg.collapse_shape with dynamic shape because of a requirement from npcomp soon (next week).

1 Like

I would really avoid this. Its not a canonicalization. It is not getting an op into its “canonical” form, rather doing something else. Can you provide a more concrete use case for this.

This is great! This is really needed for some downstream uses in IREE as well.

Potentially related, I put down some thoughts I had on redesign/refactoring the InferShapedTypeOpInterface here Better layering for `InferShapedTypeOpInterface`