memref.CopyOp for same size but different shape


I’m fairly new to LLVM/MLIR so please pardon if I sound naïve but while working with memref dialect I came across a scenario where I was trying to copy a memref into another memref with the same size but different shape and even rank, I was able to get past this problem initially by removing the SameOperandsShape constraint on CopyOp but that is obviously not the solution hence was wondering what is the recommendation for this scenario? I have to maintain the shape as it is because in this case the data is being transferred between two different memory spaces that have different stride multiple constrains, etc.

Does it warrant creating a variant of CopyOp that is relaxed on the shape constraint but verifies strides and shape alignment using some sort of AffineMap?

Zeeshan Siddiqui

Did you want to create a new buffer (allocation) and copy into it or reinterpret the same allocation with a different shape/rank, or you wanted to do the latter with the ability to realize the former at a later stage (of compilation/code generation)?