[MLIR]Does memref support null pointer?

I ran into some situation where memref.extract_aligned_pointer_as_index was able to take out a pointer to a memref.In fact, the problem’s also very simple, simply want to take the pointer, take out a memref pointer, the pointer is null.If memref doesn’t support this feature now, I’m willing to implement it.I don’t have a lot of time right now though, so does anyone have any insights? :thinking:

There is nothing that prevents memref from being null, but there is no direct way of constructing such a memref. It’s not very clear to me why would we want to construct null memrefs?

In fact, there is hardware that provides C/C++ support that transfers data in arrays via pointers. For example, the multiplication of matrices can be passed in as null or as a concrete array if there is a bias option. I’m using MLIR for support, but unfortunately I have to construct a memref every time, and the values in that memref are all 0, which causes a performance loss. I was wondering if I could add an op to the memref dialect which represents the empty memref.

For this case, I would like to hear your suggestion, I think it is good and I am willing to implement this feature. :kissing_heart:

I don’t mind adding such an op. But I’m not the only stakeholder, so let’s keep this open for a bit and see what other people think about it.

Alternatively, you can implement it in a downstream dialect for now and move later.

1 Like

Sounds good. :yum: