Proposal for adding `pure` function attribute to MLIR

I’m wondering if I can mark my function as pure? If not, I propose to add such an attribute into MLIR

It could help to give a compiler hint that operation which going to be lowered to some backend specific sub-route to have no side effects (mostly on memory). Right now if you call some custom operation MLIR thinks that this functional call has effect on memory.

"bar.foo"(%arg1) : (index) -> () {"#pure"}

A separate question if function actually changes content in a memref, while keeping memref shape unchanged or not performing reallocations/memory movements inside a function. Strictly speaking this function is not pure but some attribute may help to optimize such functions as well. If so, what should be the name of such attribute.

"bar.fill_zero_static_shapes"(%arg0: memref<?xf64, #map>) : (index) -> () {"#semi-pure"}

cc: @Hardcode84

It isn’t clear to me what you mean by this? Do you have an example? I see tensor as an immutable value type.

Sorry It’s really might be confusing. I meant memref parameter.

"bar.fill_zero_static_shapes"(%arg0: memref<?xf64, #map>) : (index) -> () {"#semi-pure"}

It modifies values inside a mermen, but not a memref itself