[Mlir-commits] [mlir] [mlir][Vector] Promote buffers accessed via dynamic subviews and memref.copy (PR #217793)
Jianhui Li
llvmlistbot at llvm.org
Sat Oct 3 15:58:39 PDT 2026
Jianhui-Li wrote:
Thanks @banach-space for your help to proper set up the code as a pre-step for this PR! I will change accordingly after your two PRs land.
// Possibly (I am not a GPU expert), but we also use Vector for other targets (e.g. CPU) 🤷🏻
// IIUC, in your case you are tryint to work around the fact that there are no "masked" elewise/reduction operations? However, it's easy for your to handle e.g. arith.select? I'm genuinely curious!
I am not sure what you exactly mean by the working around the masked elewise/reduction. We do want to achieve eventually that the dynamic access would be lowered eventually to masked vector operations, and the arith.select mask lowered from this PR for the dynamic shape memory access can be fused with reduction/matmul use to created a masked reduction/matmul op (some hw can utilize this to save compute). But I don't consider this path is a workaround, but a proper way of promote the dyanmic shape memref access to vector IR and eventually represented as masked op.
Let me also try to explain the use case we are dealing with. Say if user want to handle a dynamic shape matrix input<?x16>, load it, reduce along dim 1, and save it to output<?>. After lowering to vector IR, it first transfer_read from the input, extract the in-bound area and pad the tensor, does reduction, then extract the in-bound area and save it. Then after bufferization, these extracts are lowered to trasnfer_reading or copy a static-shaped temporary buffer to support the dynamic shape access. This PR promotes the static-shaped temporary buffer to vector, and replace transfer_read/write to vector ops (arith.select), thus remove the temporary memory access.
I actually think the CPU path would need this support as well, but there might be different ways handling it according to different use case and perform differently on different architecture.
https://github.com/llvm/llvm-project/pull/217793
More information about the Mlir-commits
mailing list