<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/120035>120035</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[MLIR][Tensor] tensor.extractOp adjustment when source is reshaped
</td>
</tr>
<tr>
<th>Labels</th>
<td>
mlir
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
hockyy
</td>
</tr>
</table>
<pre>
Wondering if there's any adjustment if a source of a extractOp function is reshaped/collapsed/expanded
is the logic of something like this correct:
```
// Process indices in the group from right to left.
// if its dynamic then need to get mixes indices
// Example:
// indexing: 2 3 4 5
// oldMixedSize: 3 | %dim2 | 8 | %dim1
// extractindices: %ex4 | 1 | 5 | %extract3
// newIndex = %extract3 + %dim1 * 5 + (8 * %dim1) * 1 + (%dim2 * 8 *
// %dim1) * %ex4 Create computation using arith here
// Accumulate indices from right to left
```
for expansion, we need to do modulo and div, for collapse we need to do mul and add
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJxkVF1v7CYQ_TX4ZXRXNpj9ePDDJtuVrtSoVVupzxjGNgkGC3Cy219fwdrJbq6ExNc5ZwbNGUQIureIDeFPhJ8KMcfB-WZw8u16LVqnrs2_zir02vagO4gDeiR0F0DYKwj1Ooc4oo3pTkBws5cILq3xEr2Q8Y8JutnKqJ0FHcBjGMSEitCzdMaIKeQ1XiZhFSpSHnVIQcC4XsukFNyIcUjhjX5DgDjoANJ5jzISdiRlHttyGeURAIDQM6Fn-NM7iSGAtkpLTHPW7r2bJ-i8G8HrfogQHRjs4iaxF6ruQMcA6mrFqGWiWbCIKmF7jDDqC34KP0b97SLGyeAtubtzbRVetO0Jy6cAQG8TW7Y1APBHjjPqRV9Q_a3_wxsvg8nuGQjlSo80r_d3J9WjwlKHNVOWXsjxUmdGBasaXxUWPHtUsfjxM6UPhJ3uUUDo0xoXCD0mnXyy3-ftmhI95G213n4mT4-QkY_hvtGWjJ89iogg3TjNUWRLzSE5Q3gdB8jWfJA5SjmPs0mk1QK_Vv2bfUh57JyH7MignSX0GT7ws_bKwejUbBwIq0Dp93SfCKudv4Nnk5FCqUI1TB3YQRTYVDtWM1oxWhdDU-2U2NNWsv22xY6pLe8Eq7jg3a4UWMlCN7SkdUWrbck4p_WGVgpbzqrdrlX7-sBJXeIotNkY8z5unO8LHcKMTUXLkvHCiBZNyD1O6Wi0J5SmbvdNwv9o5z6QujQ6xPClEHU0-V94-f3nX4SfCH_6B21wnvATxLzafDX53VfwkXpl-QruWr6YvWmGGKdkwluBeh2Hud1INxJ6ToGX6cfk3Wvqb3rO7wiEnpenvDf0_wAAAP__DBFtoA">