<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/112913>112913</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[mlir][Vector] Improve support for 0-d vectors in vector dialect lowerings
</td>
</tr>
<tr>
<th>Labels</th>
<td>
good first issue,
mlir:vector
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Groverkss
</td>
</tr>
</table>
<pre>
A number of patterns in vector dialect lowerings predate 0-d vector support and side step from 0-d vectors by converting them to scalars and then broadcasting them. An example patch fixing this: https://github.com/llvm/llvm-project/pull/112907
Some example issues:
- https://github.com/llvm/llvm-project/blob/main/mlir/lib/Dialect/Vector/Transforms/LowerVectorTransfer.cpp has patterns that convert vector.load/vector.store on 0-d vectors to memref.load/memref.store on scalars: https://github.com/llvm/llvm-project/blob/0a3347dc638594bef802d8148a77052c198ec27b/mlir/lib/Dialect/Vector/Transforms/LowerVectorTransfer.cpp#L524 . I have tested removing these, and the llvm ir generated from llvm.store with 0-d vectors is correct.
- vector.multi_reduction (https://mlir.llvm.org/docs/Dialects/Vector/#vectormulti_reduction-vectormultidimreductionop) requires the result to be a scalar when all dimensions are reduced. This causes additional corner case handling for scalars in vector.multi_reduction patterns. A better solution would be to allow 0-d vectors as result of vector.multi_reduction.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVE2PpDYQ_TXmUhpkDEzDgUPvtohW2ltWuUbGLhonxiYu07377yPTdM90oj1MlAsf5eey69WrJ4nM2SF2rP7E6lMm1zj50P0S_AXDn0TZ4PWP7ghunQcM4EdYZIwYHIFxcEEVfQBtpEUVwforBuPOBEtALSMCf9F3EK3L4kME6TSQ0QgUcYEx-PkdimD4Acq7C4Zo3BnihDNED6SklYG2zXFCB0PwUitJD1QORwf4Xc6LxXRHNcFovt9WDbHyCFOMS_pgomeiP5s4rUOu_MxEb-3l_npZgv8DVWSiX1ZrmeiLQrT8wPiJ8ePt-auf8XGWIVpxy_sO8fLx0wbrByb6WRqXXtaEhDEpdrrxy0T_28YSE_23IB2NPszERP818X5busUx5GpZYJL01q44yXindmc7t15qJvr9j6IPCN499SN6mHEOON7B-98DvLfmPzG818xlWVYHrV7Lpm6rAceGC90UVSMPB14LVbQNKnEY_idemCi_1qKCHL7AJC8IESmihoCzv-x6ImTi811ukK4NJsAZHQaZsJtuU3gn4mri9MSbIVA-BFQxfxbGTva82mh-D6hXFY13wETzTF-qNN9O8OHMRK-9orea6X3RTJS3rP9I-vIuqs38iPuFiRYC_rWagLRVGJBWG1O3BwS5NxWuadSktaDNjI6MdwQyJLReFeocvk2pTrkSEkitTcoubarcYQAlCWGSTtvE6phMYJ_jh3f8i4e7XnM4woDpG8jbdVu7-tXqdMHo06389YlxSfcq_PiT7Hmmu1K3ZSsz7IqDaMWrqBqeTZ2uqoKPXCksx0Lp8nWUjWp0q7nUvBqbzHSCi6rgRVNUVVE0-aEd2rotqhoPRTk2nFUcZ2nso2fZ5gxdso-izKwc0NJms0KcvdcwmkDxZh9MCCY-MyE2eZfHy95ZkSw5dNvUDOuZWMWtoUhvZ0QT7Wbe2876xOpPuyzqE3yZl-TjD-tNHXjS6M8dPFuD7T48z7sX3jyzKLNLJ_4OAAD__5gbMGs">