<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63212>63212</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
MLIR, TOSA: Zero-size tensor crashes tosa-to-tensor
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
eric-k256
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
mgehre-amd
</td>
</tr>
</table>
<pre>
```
func.func @test_reshape_downrank_zero(%arg0: tensor<6x1x0xf32>) -> tensor<6x0xf32> {
%0 = "tosa.reshape"(%arg0) {new_shape = array<i64: 6, 0>} : (tensor<6x1x0xf32>) -> tensor<6x0xf32>
return %0 : tensor<6x0xf32>
}
```
run with
`mlir-opt test.mlir --tosa-to-tensor`
crashes in `createReassociationMapsForCollapse` due to https://github.com/llvm/llvm-project/blob/9bccb5ba0ddec929b4cb54825331fcb548b495e3/mlir/lib/Conversion/TosaToTensor/TosaToTensor.cpp#L107
being out of bounds.
I'm not sure how the correct tensor IR would look like for this case.
Tensors where a dimension have zero size seems to be allowed by the TOSA spec.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUk0FvqzgQxz_NcBmBjB0gHDjkJQ-p0ntaqdvTXiobT4K3xEa2adr36VemZN_2sIdKyNgMM_Ob8X9kCOZiiTqovgHn5M2Qv_CqBs6hOmVyiaPz3fVCo6dcXnWmnH7voGbbw07ADufFDkVaEHYsUojPnsIoZ3rW7ma9tC_Pv8g74HvglfQXBuKAkWxwHsSxfivf2NtZcBDfgbeYg_j-X-vdhtB8-8iHCLxiCOKEwHl0QRZbwoT9Owtvk4-l2_NqXB2k9_IdxNHUu0RRAz8iS5mbE6YPwPdfJrtTeYqLt3e4w___Cs1p23xupF8s3kwc_zVeJ-NzN0dMXS3SCfM8FZxHl2_h786Dl2GkgMYi1GzwJCM9kgzBDUZG4-xPOYfe-aObJjkHgpqhXgijwzHGOYA4AO-B9xcTx0UVg7sC76fp9f7KZ-_-piEC79XkFPC-VcOgKiWZ1jS0vFW7QVW7Pa-EKM_rVu3aigTwPrGnOCb5HZ19JR-Ms8D7Jxfkk3v6KObzsRjmGbj4UbLmo0ZFxl7QLRHdGZVbrA7F1qx1fQDeXNG6iGHxhKO7YRwJB-c9DXG7EHx4xJtbJo2Tcy84mRfCs_MYRxNwkIG2kB8MAW8jeUKJ2lzJJmgc5SthkjQG84swEF1D6qMilNPkbqRRva-Zn_7484BhpqHIdCd0K1qZUVfW-1qwhokqGzutmx2rRVWzfUNnUUoh92rQJJtW8b1uM9NxxgWrWVsy0ZRVIZnel6ptea0qrlkFO0ZXaaYi3VLh_CUzISzU1YKXPJukoilsA27phqtxG3DfrTerlkuAHZtMiOF3lGjiRN3PHw-PaUpSKUnVf5F3-Vr31s678D7rMlv81H1ZWCtbAN6v7P8EAAD__9Vib4s">