[Standard] `MemRefReshapeOp` with constant shape

Hi,
I want to use MemRefReshapeOp with a constant shape, but the shape operand must have MemRefType which does not have a constant representation (at least not with ConstantOp).

I wanted to know what is the suggested approach for this issue?
Maybe we need to add support for VectorType as well (for the shape), and then be able to use a constant? Maybe an attribute?

Thanks.

Would memref_reinterpret_cast do what you want? As the shape is constant, you can just recompute the strides to match.

@ekatz I was planning to add an alternative argument for memref_reshape op, so that the shape could be passed as a memref or as a variadic index parameter. If the memref has statically-known length, it can be canonicalized into the version with indices.

Thanks for both of you.
@pifon2a I’ll watch for your changes. :slight_smile: