Hello everyone,
This topic is related to the “RFC Strided MemRef Proposal”.
The TL;DR is that a MemRefType currently has no established way of tying the symbols used for dynamic sizes to the symbols used in the layout expressions.
For instance, consider the first case:
memref<?x?x?xf32, (i, j, k)[s0, s1, s2] -> (s0 + i + s1 * j + s2 * k)>
that can also be thought of as
memref<?x?x?xf32, offset:s0, strides=[s2, s1, 1]>
and the second case:
memref<?x?x?xf32, (i, j, k)[s0, s1, s2] -> (s0 * i + s1 * j + s2 * k)>
that can also be thought of as
memref<?x?x?xf32, offset:0, strides=[s2, s1, s0]>
Both forms are perfectly valid but have very different implications on the layout depending on the relationship between s0,s1,s2
and the ?
in memref<?x?x?xf32>
.
Assuming a memref with k
symbolic sizes, I would personally be enclined to adopt the convention that the first k
symbols in a layout map must be the memref sizes in their order. Optionally, additional symbols may be specified starting from s_{k+1}
.
Note that this is purely a MemRefType concern and does not leak into the normalized descriptor or the ABI. As a reminder, the normalized descriptor is:
template <typename Elem, size_t Rank>
struct {
Elem *ptr;
int64_t offset;
int64_t sizes[Rank];
int64_t strides[Rank];
};
and can accomodate the different cases.
What are people’s thoughts on this?