LLVM Discussion Forums

How to convert NCHW memref into NHWC memref?

I have incoming NCHW tensor (converted to a memref while lowering) but linalg::ConvOp accept only NHWC format for input, what is the best way to make a conversion? I tried linalg::ReshapeOp but it seems that this operation at least right now is mostly for rearranging adressing on contiguous layout, not for rearranging the data inside itself.

I suspect linalg.copy should be able to achieve this? https://mlir.llvm.org/docs/Dialects/Linalg/#linalgcopy-linalgcopyop

1 Like