How to get access indices in AffineLoadOp

Hi,

I have following two AffineLoadOp instructions in an AffineForOp:

affine.for %arg0 = 1 : 9 {
     %a = affine.load %T[%arg0] : memref<10xf32>
     %b = affine.load %T[%arg0 + 1] : memref<10xf32>
}

I am trying to get the access indices of the two AffineLoadOp instructions, i.e. the access indices of the first AffineLoadOp should be %arg0, the second should be %arg0 + 1. I tried with .indices() method of the AffineLoadOp, but in both two cases, it only returns <block argument> of type 'index' at index: 0 , it’s true for the first AffineLoadOp, but in the second, it should contain information about +1.

can any one help me on this? Thank you so much in advance.

The actual indexing expression is obtained by applying the affine map to the indices.
In your case the affine map encodes the +1 and should resemble: affine_map<(d0)[] -> (d0 + 1)> it is indeed applied to only %arg0.
The parser / printer of affine.load/store elides these affine_map, you should be able to see them by using mlir-opt with the flag to print generic form (I forget what it is offhand).

1 Like

Thank you so much! It’s quite helpful~