<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/107202>107202</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[mlir][sparse] `disassemble` of COO returns incorrect shape of `%index` with Python bindings
</td>
</tr>
<tr>
<th>Labels</th>
<td>
mlir
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
mtsokol
</td>
</tr>
</table>
<pre>
Hi!
I noticed that in Python disassembling COO format, when `pos` and `index` shapes are dynamic returns an incorrect shape for `index`:
```mlir
%c0 = arith.constant 0 : index
%pos = tensor.empty(%c0) : tensor<?xindex>
%c0_0 = arith.constant 0 : index
%index = tensor.empty(%c0_0) : tensor<?x2xindex>
```
The shape of `index` tensor is always `[0, 2]` where it should be `[nnz, 2]`. Here's a Python script that fully reproduces the issue:
https://gist.github.com/mtsokol/af61fd0c6fbe885cb7db417ba0e3800a
Tested on LLVM `19.1.0-rc3`
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMU0Fv8zYM_TXyhaghyXYcH3xomwXfgA7dYdi1kCU61mZLhii3zX79IDtp02IDPiCIQemRFPneU0T25BBbVj2w6pCpJQ4-tFMk_7cfs86bc_vDMimA8QPj99v_r-B8tBoNxEFFsA5-P8fBOzCWFBFO3WjdCR6fn6H3YVKRyUd4G9AB2_HZE9txUM6kyDqD7ymmQc1IoAKCOTs1WQ0B4xIcgXJgnfYhoI4bLpW9zWbF_e370sn6m0YbLkey0hxYcQAVbBxy7R1F5SKkw3vYCl2Rs6cVGtGRDzlOczwzuV9rMNmsGdsdKx5ZcXzf0otfbnq9_HS3Nfrffi__3VF-9IRvM98u4o8BLwvz_Zdtb7XAEqjxTZ0pXbLqgSeiJKsOCfM2YECwaeV-GQ10eEE5988NLocfGJDJmkBddUA62Dlu6uiXcTxDwDl4s2gkiAOCJVrwg7UhxplSJI9MHk-WYn6ycVi6XPuJyeNFjkweVb8TveF613e431e6q01XirpTHIs95-rL8EgRDXgHT09__pbeLppc5Pwu6ILteGbawjRFozJsRS2rshR8X2dDW4hKIG9EXzdCqa40VVd0XJeoi32pa5HZVnJZ8oaXvBFC1rlSel93RpU7KXihBSs5TsqO-Ti-TrkPp2ydtxW8llxmo-pwpNVyUq4SlWmXWWgT_q5bTsRKPlqK9Fkh2jiuNl0TqgOrHmhWgZBVhzTbp_Uwkef71X5XC333zyaHq_hWtm0crvR11hnrTpQtYWy_k3PDS3rc5XM3B_8X6sjkcZ2VmDxexn1t5b8BAAD__9ozWAo">