llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[mlir][linalg] `linalg.generic`: requirement for the output buffer to be written to fully?

Open pingshiyu opened this issue 2 years ago • 1 comments

After observing some interesting behaviour recently, I learned (from @ftynse) that there is a convention where linalg.generic operations should always write to the output buffer fully, i.e. write to every element in the buffer.

As far as I can see, the closest wording I can find that hints at this convention/behaviour on the documentation is as follows - outside of the description of the linalg.generic operation: A linalg.generic op represents a perfectly nested loop nest that writes the entire memory region.

It is unclear what the behaviour should be when not all of the memory region has been written to. Such programs can certainly be expressed within the current IR, and these programs are not rejected by the compiler (for instance the example from the discourse post)

Should we add something to linalg.generic documentation to clarify the behaviour when the outputs are not fully written? If so, should it be undefined behaviour, or something more defined, like only "the indices written to are defined"?

pingshiyu avatar Jun 02 '24 23:06 pingshiyu

@llvm/issue-subscribers-mlir-linalg

Author: Jacob Yu (pingshiyu)

After observing [some interesting behaviour ](https://discourse.llvm.org/t/linalg-generic-issue-understanding-indexing-map-semantics/79256) recently, I learned (from @ftynse) that there is a _convention_ where `linalg.generic` operations should always write to the output buffer _fully_, i.e. write to every element in the buffer.

As far as I can see, the closest wording I can find that hints at this convention/behaviour on the documentation is as follows - outside of the description of the linalg.generic operation: A linalg.generic op represents a perfectly nested loop nest that writes the entire memory region.

It is unclear what the behaviour should be when not all of the memory region has been written to. Such programs can certainly be expressed within the current IR, and these programs are not rejected by the compiler (for instance the example from the discourse post)

Should we add something to linalg.generic documentation to clarify the behaviour when the outputs are not fully written? If so, should it be undefined behaviour, or something more defined, like only "the indices written to are defined"?

llvmbot avatar Jun 03 '24 03:06 llvmbot