<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/94180>94180</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[mlir][linalg] `linalg.generic`: requirement for the output buffer to be written to fully?
</td>
</tr>
<tr>
<th>Labels</th>
<td>
mlir
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
pingshiyu
</td>
</tr>
</table>
<pre>
After observing [some interesting behaviour ](https://discourse.llvm.org/t/linalg-generic-issue-understanding-indexing-map-semantics/79256) recently (from @ftynse), I learned that there is a _convention_ that `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](https://mlir.llvm.org/docs/Dialects/Linalg/#linalggeneric-linalggenericop) 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 semantics 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"?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8Vc2O-jYQfxpzGYGyDiFw4MAWIa3UU_8PgEwySdw6djrjwObtq3FgYdtVJQQhGdvz-5oYZtt6xL0q3lVxXJgxdoH2g_Utd3YaF5dQT_tDE5EgXBjpan0Lqnjn0CNYH5GQo9y7YGeuNowEqjgqve1iHFjlB6VPSp9qy1UYiXHl3LVfBWqVPkWlT85649plix7JVkvLPOJy9DUSR-Nr69ul9TV-ykVvhiVjb3y0FSt9Kne62Ci9A8IKfXQTKL1tKPSg1lkTJ8-o9E7p3-ADHBryWEPsTITYISFYBgPnKvgr-miDP88P1Sabm1rdm1KbDMKAZKSIgbswuhqMu5mJ4UY2Is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