[RFC] Memref of custom types

This is a frequently requested feature. I’d like to extend memref to support arbitrary element types, and we now have sufficient infrastructure support to do so.

The extension can be implemented as follows. In addition to the types that are currently supported, memref can support element types that implement the newly added MemRefElementTypeInterface, which provides functionality necessary for memref to reason about the type. Given the current use, this functionality provides the size and alignment requirements of the element type. The default implementation of the interface queries the DataLayout interfaces to obtain size and alignment information. An interface separate from DataLayoutTypeInterface allows types to explicitly opt into being supported as memref element types and enables independent evolution of the two interfaces.

1 Like

Will this feature support something like memref of memref (e.g. memref<10xmemref<10xf32>>)?

If memref implements MemrefElementTypeInterface, yes, it’s not much different from other types.

This looks great to have. I recall this topic was discussed on another thread in more detail several months ago – as to what information we really expect from types that want to be memref element types. (You had a detailed post there but I don’t recall the thread title.)