[Mlir-commits] [mlir] [mlir][vector] Add fold to transfer_{read, write} vector<1xT> (PR #196598)
Andrzej Warzyński
llvmlistbot at llvm.org
Thu May 14 06:54:01 PDT 2026
banach-space wrote:
> there is no conceptual separation between vector.transfer_read and vector.load in the doc that I can locate at the moment (any pointer?).
Indeed, there is no and, AFAIK, never has been.
> I misread the documentation a bit
It's not been updated for quite some time, so that's no surprise. That said, as I [hinted](https://github.com/llvm/llvm-project/pull/196598#issuecomment-4433247084) earlier, treating some `Vector` Ops as higher level than the others is just one possible _interpretation_ (as opposed "the intended design of Vector").
> What I meant is that the lowering handles the code produced by these patterns, not the code that matches this pattern.
👍🏻
Btw, is there an example that shows that this won't lower to `vector.transfer_read` when the permutation map is not a minor identity ?
```mlir
func.func @canonicalize_transfer_read_size1_map(%m: memref<4x3xf32>, %i: index, %j: index, %pad: f32) -> vector<1xf32> {
%v = vector.transfer_read %m[%i, %j], %pad {in_bounds = [true], permutation_map = affine_map<(d0, d1) -> (d0)>} : memref<4x3xf32>, vector<1xf32>
return %v : vector<1xf32>
}
module attributes {transform.with_named_sequence} {
transform.named_sequence @__transform_main(%module: !transform.any_op {transform.readonly}) {
%func = transform.structured.match ops{["func.func"]} in %module : (!transform.any_op) -> !transform.any_op
transform.apply_patterns to %func {
transform.apply_patterns.vector.lower_transfer max_transfer_rank = 1
} : !transform.any_op
transform.yield
}
}
```
---
I would prefer the other approach, but this is also valid and a clear improvement, LGTM (please double check that test ^^^ though, thanks!)
https://github.com/llvm/llvm-project/pull/196598
More information about the Mlir-commits
mailing list