Xilinx / mlir-aie

An MLIR-based toolchain for AMD AI Engine-enabled devices.
Other
308 stars 90 forks source link

Choose `dimensions` or `sizes` + `strides` for user-facing operations #1922

Open hunhoffe opened 1 week ago

hunhoffe commented 1 week ago

Right now, some operations take dimensions and some operations take sizes and strides.

For clarity, but also some implementation considerations, I think it would make sense to change to sizes/strides.

Some pros for moving to sizes/strides are:

This came to my attention through comments of @fifield and @andrej in https://github.com/Xilinx/mlir-aie/pull/1919

As this would be a change that touches many things, I'm recording outside of the PR for discussion and so it does not become a blocker to that PR.

andrej commented 1 week ago

For dma_bds using the task/chain syntax, each dma_db should have at max 3 sizes and at max 4 strides; this is a condition that is not easy to express clearly when using dimensions

Why only max 3 sizes but 4 strides?

Copying my examples from the review of #1919 on why repeat_count and the higest-dimension size/wrap aren't the same:

Examples These examples assume a highest-dimension stride of 2. If the highest-dimension size/wrap is 3, the higest-dimension stride (=iteration step) is 2, and the repeat count is 6, the highest dimension offset added will be
Task repetition:             0   1   2   3   4   5  (repeat count = 6)
Highest-dim offset added:    0   2   4   0   2   4
                                         ^
                                      wrap (=3)
If the highest-dimension wrap matches the repeat count of the task, the iteration step will be added each repetition:
Task repetition:             0   1   2   3   4   5  (repeat count = 6)
Highest-dim offset added:    0   2   4   6   8   10 
                                                     ^
                                                 wrap (=6)
In the other extreme, if the wrap is 1, the iteration step never gets added (BD repeated with no offset).
Task repetition:             0   1   2   3   4   5  (repeat count = 6)
Highest-dim offset added:    0   0   0   0   0   0
                             ^   ^   ^   ^   ^   ^
                             w.  w.  w.  w.  w.  wrap(=1)
hunhoffe commented 1 week ago

Ah I see what you are saying now. I was having trouble parsing your examples because it's hard to understand "highest dimension" when the highest dimension from the perspective of the hardware and the perspective of the user are not always the same thing.

But I think I understand now. I've edited the issue to remove that point. Thanks for explaining again!