[Mlir-commits] [mlir] [mlir][vector] Restrict DropInnerMostUnitDimsTransferRead (PR #94904)

Andrzej Warzyński llvmlistbot at llvm.org
Tue Jun 11 11:06:49 PDT 2024


banach-space wrote:

> Looking at indices is convenient and correct. I wonder if looking at in_bounds attribute is better here?

I think that there are two different (both important) concerns here:
*  the input indices have to be present when calculating the starting idx _after_ collapsing,
* the `in_bounds` attribute can be used to decide whether the access is "valid" to begin with.

I'm only looking at the former concern. In particular, for this example:
```mlir
func.func @negative_example(%A: memref<16x1xf32>, %i:index, %j:index) -> (vector<8x1xf32>) {
  %f0 = arith.constant 0.0 : f32
  %1 = vector.transfer_read %A[%i, %j], %f0 : memref<16x1xf32>, vector<8x1xf32>
  return %1 : vector<8x1xf32>
}
```

what should be the output after collapsing? This is what you will get today:
```mlir
  func.func @negative_example(%arg0: memref<16x1xf32>, %arg1: index, %arg2: index) -> vector<8x1xf32> {
    %cst = arith.constant 0.000000e+00 : f32
    %subview = memref.subview %arg0[0, 0] [16, 1] [1, 1] : memref<16x1xf32> to memref<16xf32, strided<[1]>>
    %0 = vector.transfer_read %subview[%arg1], %cst : memref<16xf32, strided<[1]>>, vector<8xf32>
    %1 = vector.shape_cast %0 : vector<8xf32> to vector<8x1xf32>
    return %1 : vector<8x1xf32>
  }
```
This is not correct - `%arg2` is completely ignored. And that's what I'm disabling.

Please let me know if this makes sense - I hope that I'm not missing something important myself 😅 

https://github.com/llvm/llvm-project/pull/94904


More information about the Mlir-commits mailing list